prev_alias=NULL;
for (alias=AliasData->First ; alias ; alias=alias->Next) {
if (alias->Type==ALIASTYPE_Name && !strcmp(Name,alias->Name.Mask)) {
- debuga(_("Duplicate aliasing directive for name %s\n"),Name);
+ debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for name %s\n"),Name);
return(0);
}
prev_alias=alias;
// insert into the list
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the user name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
return(-1);
}
new_alias->Type=ALIASTYPE_Name;
new_alias->Name.Wildcards=wildcards;
new_alias->Name.Mask=StringBuffer_Store(AliasData->StringBuffer,Name);
if (!new_alias->Name.Mask) {
- debuga(_("Not enough memory to store the user name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
free(new_alias);
return(-1);
}
len=(int)(ReplaceE-Replace);
new_alias->Alias=StringBuffer_StoreLength(AliasData->StringBuffer,Replace,len);
if (!new_alias->Alias) {
- debuga(_("Not enough memory to store the user name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
free(new_alias);
return(-1);
}
int bit=alias->Ipv4.NBits%8;
if ((byte<1 || memcmp(ipv4,alias->Ipv4.Ip,byte)==0) && (bit==0 || (ipv4[byte] ^ alias->Ipv4.Ip[byte]) & (0xFFU<<(8-bit)))==0) {
if (nbits==alias->Ipv4.NBits)
- debuga(_("Duplicate aliasing directive for IPv4 address %d.%d.%d.%d/%d\n"),
+ debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for IPv4 address %d.%d.%d.%d/%d\n"),
ipv4[0],ipv4[1],ipv4[2],ipv4[3],nbits);
else
- debuga(_("IPv4 aliasing directive ignored for IPv4 address %d.%d.%d.%d/%d as it is"
+ debuga(__FILE__,__LINE__,_("IPv4 aliasing directive ignored for IPv4 address %d.%d.%d.%d/%d as it is"
" narrower than a previous one (%d.%d.%d.%d/%d\n"),
ipv4[0],ipv4[1],ipv4[2],ipv4[3],nbits,
alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],alias->Ipv4.Ip[3],
// insert into the list
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
new_alias->Type=ALIASTYPE_Ipv4;
len=(int)(ReplaceE-Replace);
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
free(new_alias);
return(-1);
}
new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
}
if (!new_alias->Alias) {
- debuga(_("Not enough memory to store the IPv4 aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the IPv4 aliasing directives\n"));
free(new_alias);
return(-1);
}
int bit=alias->Ipv6.NBits%16;
if ((word<1 || memcmp(ipv6,alias->Ipv6.Ip,word*2)==0) && (bit==0 || (ipv6[word] ^ alias->Ipv6.Ip[word]) & (0xFFFFU<<(16-bit)))==0) {
if (nbits==alias->Ipv6.NBits)
- debuga(_("Duplicate aliasing directive for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
+ debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
ipv6[0],ipv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits);
else
- debuga(_("IPv6 aliasing directive ignored for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d as it is"
+ debuga(__FILE__,__LINE__,_("IPv6 aliasing directive ignored for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d as it is"
" narrower than a previous one (%x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
ipv6[0],ipv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits,
alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],alias->Ipv6.Ip[3],alias->Ipv6.Ip[4],
// insert into the list
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
new_alias->Type=ALIASTYPE_Ipv6;
len=ReplaceE-Replace;
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
free(new_alias);
return(-1);
}
new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
}
if (!new_alias->Alias) {
- debuga(_("Not enough memory to store the IPv6 aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the IPv6 aliasing directives\n"));
free(new_alias);
return(-1);
}
for (End=buf ; *End && *End!=Delimiter ; End++) {
if (*End=='\\') {
if (End[1]=='\0') {
- debuga(_("Invalid NUL character found in regular expression\n"));
+ debuga(__FILE__,__LINE__,_("Invalid NUL character found in regular expression\n"));
return(-1);
}
End++; //ignore the escaped character
}
}
if (*End!=Delimiter) {
- debuga(_("Unterminated regular expression\n"));
+ debuga(__FILE__,__LINE__,_("Unterminated regular expression\n"));
return(-1);
}
*End++='\0';
// store it
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
new_alias->Type=ALIASTYPE_Pcre;
new_alias->Next=NULL;
new_alias->Regex.Re=pcre_compile(buf,0,&PcreError,&ErrorOffset,NULL);
if (new_alias->Regex.Re==NULL) {
- debuga(_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
+ debuga(__FILE__,__LINE__,_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
free(new_alias);
return(-1);
}
len=strlen(Replace);
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
pcre_free(new_alias->Regex.Re);
return(-1);
}
new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
free(tmp);
if (!new_alias->Alias) {
- debuga(_("Not enough memory to store the regex aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the regex aliasing directives\n"));
free(new_alias);
return(-1);
}
if (Alias_StoreRegexp(AliasData,String+3)<0)
return(-1);
#else
- debuga(_("PCRE not compiled in therefore the regular expressions are not available to alias items\n"));
+ debuga(__FILE__,__LINE__,_("PCRE not compiled in therefore the regular expressions are not available to alias items\n"));
return(-1);
#endif
}
switch (alias->Type)
{
case ALIASTYPE_Name:
- debuga(_(" %s => %s\n"),alias->Name.Mask,alias->Alias);
+ debuga(__FILE__,__LINE__,_(" %s => %s\n"),alias->Name.Mask,alias->Alias);
break;
case ALIASTYPE_Ipv4:
- debuga(_(" %d.%d.%d.%d/%d => %s\n"),alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],
+ debuga(__FILE__,__LINE__,_(" %d.%d.%d.%d/%d => %s\n"),alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],
alias->Ipv4.Ip[3],alias->Ipv4.NBits,alias->Alias);
break;
case ALIASTYPE_Ipv6:
- debuga(_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],
+ debuga(__FILE__,__LINE__,_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],
alias->Ipv6.Ip[3],alias->Ipv6.Ip[4],alias->Ipv6.Ip[5],alias->Ipv6.Ip[6],alias->Ipv6.Ip[7],
alias->Ipv6.NBits,alias->Alias);
break;
case ALIASTYPE_Pcre:
- debuga(_(" Re => %s\n"),alias->Alias);
+ debuga(__FILE__,__LINE__,_(" Re => %s\n"),alias->Alias);
break;
}
}
return;
if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",outdirname,uinfo->filename)>=sizeof(htname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s/.htaccess\n",outdirname,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_auth=fopen(htname,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),htname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),htname,strerror(errno));
exit(EXIT_FAILURE);
}
if ((fp_in=fopen(AuthUserTemplateFile,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno));
exit(EXIT_FAILURE);
}
}
}
if (fclose(fp_auth)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),htname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),htname,strerror(errno));
exit(EXIT_FAILURE);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno));
exit(EXIT_FAILURE);
}
void authfail_open(void)
{
if ((ReportType & REPORT_TYPE_AUTH_FAILURES) == 0) {
- if (debugz>=LogLevel_Process) debugaz(_("Authentication failures report not produced as it is not requested\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Authentication failures report not produced as it is not requested\n"));
return;
}
if (Privacy) {
- if (debugz>=LogLevel_Process) debugaz(_("Authentication failures report not produced because privacy option is active\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Authentication failures report not produced because privacy option is active\n"));
return;
}
snprintf(authfail_unsort,sizeof(authfail_unsort),"%s/authfail.int_unsort",tmp);
if ((fp_authfail=MY_FOPEN(authfail_unsort,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),authfail_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
return;
if (fp_authfail)
{
if (fclose(fp_authfail)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),authfail_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_authfail=NULL;
if (!authfail_exists) {
if (!KeepTempLog && authfail_unsort[0]!='\0' && unlink(authfail_unsort))
- debuga(_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
authfail_unsort[0]='\0';
- if (debugz>=LogLevel_Process) debugaz(_("Authentication failures report not produced because it is empty\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Authentication failures report not produced because it is empty\n"));
return;
}
if (debugz>=LogLevel_Process)
- debuga(_("Creating authentication failures report...\n"));
+ debuga(__FILE__,__LINE__,_("Creating authentication failures report...\n"));
snprintf(authfail_sort,sizeof(authfail_sort),"%s/authfail.int_log",tmp);
snprintf(report,sizeof(report),"%s/authfail.html",outdirname);
snprintf(csort,sizeof(csort),"sort -b -t \"\t\" -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", tmp, authfail_sort, authfail_unsort);
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=MY_FOPEN(authfail_sort,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),authfail_sort,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),authfail_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(authfail_unsort)) {
- debuga(_("Cannot delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
authfail_unsort[0]='\0';
if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("USERID"),_("IP/NAME"),_("DATE/TIME"),_("ACCESSED SITE"));
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,'\t')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("Invalid user ID in file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Invalid user ID in file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("Invalid IP address in file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Invalid IP address in file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),authfail_sort);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),authfail_sort);
exit(EXIT_FAILURE);
}
if (sscanf(data,"%d/%d/%d",&day,&month,&year)!=3) continue;
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,authfail_sort);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,authfail_sort);
exit(EXIT_FAILURE);
}
fputs("</td></th>\n",fp_ou);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),authfail_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),authfail_sort,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(authfail_sort)) {
- debuga(_("Cannot delete \"%s\": %s\n"),authfail_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),authfail_sort,strerror(errno));
exit(EXIT_FAILURE);
}
{
if (fp_authfail) {
if (fclose(fp_authfail)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),authfail_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_authfail=NULL;
}
if(authfail_unsort[0]) {
if (!KeepTempLog && unlink(authfail_unsort)==-1)
- debuga(_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
}
}
arq="/var/log/squid/access.log";
if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arq);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arq);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,' ')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),arq);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),arq);
exit(EXIT_FAILURE);
}
tt=atoi(data);
longline_destroy(&line);
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
}
snprintf(guard_ou,sizeof(guard_ou),"%s/dansguardian.int_log",tmp);
if(access(DansGuardianConf, R_OK) != 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),DansGuardianConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),DansGuardianConf,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_guard=fopen(DansGuardianConf,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),DansGuardianConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),DansGuardianConf,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(guard_in,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
if(strstr(buf,"loglocation ") != 0) {
getword_start(&gwarea,buf);
if (getword_skip(MAXLEN,&gwarea,'\'')<0 || getword(loglocation,sizeof(loglocation),&gwarea,'\'')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),DansGuardianConf);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),DansGuardianConf);
exit(EXIT_FAILURE);
}
- if (debug) debuga(_("Using the dansguardian log file \"%s\" found in your configuration file \"%s\"\n"),
+ if (debug) debuga(__FILE__,__LINE__,_("Using the dansguardian log file \"%s\" found in your configuration file \"%s\"\n"),
loglocation,DansGuardianConf);
break;
}
}
if (fclose(fp_guard)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),DansGuardianConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),DansGuardianConf,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug)
- debuga(_("Reading DansGuardian log file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Reading DansGuardian log file \"%s\"\n"),loglocation);
if((fp_in=MY_FOPEN(loglocation,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),loglocation,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),loglocation,strerror(errno));
exit(EXIT_FAILURE);
}
getword_start(&gwarea,buf);
if (getword_atoi(&year,&gwarea,'.')<0 || getword_atoi(&mon,&gwarea,'.')<0 ||
getword_atoi(&day,&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword_atoi(&hour,&gwarea,':')<0 || getword(minsec,sizeof(minsec),&gwarea,' ')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword(user,sizeof(user),&gwarea,' ')<0) {
- debuga(_("Invalid user in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword(ip,sizeof(ip),&gwarea,' ')<0) {
- debuga(_("Invalid IP address in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid IP address in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword_skip(MAXLEN,&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,'/')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,' ')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
if (getword_skip(255,&gwarea,' ')<0 ||
getword(code1,sizeof(code1),&gwarea,' ')<0 || getword(code2,sizeof(code2),&gwarea,' ')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),loglocation);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),loglocation);
exit(EXIT_FAILURE);
}
idata = year*10000+mon*100+day;
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),loglocation,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),loglocation,strerror(errno));
exit(EXIT_FAILURE);
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug)
- debuga(_("Sorting file \"%s\"\n"),guard_ou);
+ debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),guard_ou);
snprintf(tmp6,sizeof(tmp6),"sort -t \"\t\" -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
cstatus=system(tmp6);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),tmp6);
+ debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),tmp6);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(guard_in)) {
- debuga(_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
}
snprintf(dansguardian_in,sizeof(dansguardian_in),"%s/dansguardian.int_log",tmp);
if(!dansguardian_count) {
if (!KeepTempLog && unlink(dansguardian_in))
- debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
- if (debugz>=LogLevel_Process) debugaz(_("Dansguardian report not generated because it is empty\n"));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Dansguardian report not generated because it is empty\n"));
return;
}
sprintf(report,"%s/dansguardian.html",outdirname);
if((fp_in=MY_FOPEN(dansguardian_in,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),dansguardian_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),dansguardian_in,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
getword_start(&gwarea,buf);
if (getword(user,sizeof(user),&gwarea,'\t')<0 || getword(date2,sizeof(date2),&gwarea,'\t')<0 ||
getword(hour,sizeof(hour),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),dansguardian_in);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),dansguardian_in);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),dansguardian_in);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),dansguardian_in);
exit(EXIT_FAILURE);
}
if (getword(rule,sizeof(rule),&gwarea,'\n')<0) {
- debuga(_("Invalid rule in file \"%s\"\n"),dansguardian_in);
+ debuga(__FILE__,__LINE__,_("Invalid rule in file \"%s\"\n"),dansguardian_in);
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),dansguardian_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),dansguardian_in,strerror(errno));
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"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(dansguardian_in)) {
- debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
exit(EXIT_FAILURE);
}
uscan=userinfo_startscan();
if (uscan == NULL) {
- debuga(_("Cannot enumerate the user list\n"));
+ debuga(__FILE__,__LINE__,_("Cannot enumerate the user list\n"));
exit(EXIT_FAILURE);
}
while ( (uinfo = userinfo_advancescan(uscan)) != NULL ) {
}
user_find(userlabel,MAX_USER_LEN, u2);
userinfo_label(uinfo,userlabel);
- if(debug) debuga(_("Reading user file \"%s/%s\"\n"),tmp,uinfo->filename);
+ if(debug) debuga(__FILE__,__LINE__,_("Reading user file \"%s/%s\"\n"),tmp,uinfo->filename);
sort_users_log(tmp,debug,uinfo);
if (snprintf(tmp3,sizeof(tmp3),"%s/%s.user_log",tmp,uinfo->filename)>=sizeof(tmp3)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.user_log\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_in=MY_FOPEN(tmp3,"r"))==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 ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
getword(accip,sizeof(accip),&gwarea,'\t')<0 ||
getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
getword(acccode,sizeof(acccode),&gwarea,'\t')<0 || getword_atoll(&accelap,&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
- debuga(_("Invalid smart info in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid smart info in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
if(!same_url || new_user){
if(!fp_ou && (fp_ou=MY_FOPEN(DataFile,"w"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),DataFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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);
ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
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);
}
longline_destroy(&line);
userinfo_stopscan(uscan);
if (oldurl) free(oldurl);
if (fp_ou && fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),DataFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),DataFile,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug)
- debuga(_("Datafile %s written successfully\n"),DataFile);
+ debuga(__FILE__,__LINE__,_("Datafile %s written successfully\n"),DataFile);
}
void saverecs(FILE *fp_ou, const struct userinfostruct *uinfo, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache)
TRANSLATORS: The last %s is the command used to uncompress
the log file such as zcat ou bzip2.
*/
- debuga(_("Decompressing log file \"%s\" with %s\n"),arq,"zcat");
+ debuga(__FILE__,__LINE__,_("Decompressing log file \"%s\" with %s\n"),arq,"zcat");
if (snprintf(cmd,sizeof(cmd),"zcat \"%s\"",arq)>=sizeof(cmd)) {
- debuga(_("decompression command too long for log file %s\n"),arq);
+ debuga(__FILE__,__LINE__,_("decompression command too long for log file %s\n"),arq);
exit(EXIT_FAILURE);
}
*pipe=true;
fi=popen(cmd,"r");
}
else if(arqlen>4 && strcmp(arq+arqlen-4,".bz2") == 0) {
- debuga(_("Decompressing log file \"%s\" with %s\n"),arq,"bzcat");
+ debuga(__FILE__,__LINE__,_("Decompressing log file \"%s\" with %s\n"),arq,"bzcat");
if (snprintf(cmd,sizeof(cmd),"bzcat \"%s\"",arq)>=sizeof(cmd)) {
- debuga(_("decompression command too long for log file %s\n"),arq);
+ debuga(__FILE__,__LINE__,_("decompression command too long for log file %s\n"),arq);
exit(EXIT_FAILURE);
}
*pipe=true;
fi=popen(cmd,"r");
}
else if(arqlen>2 && strcmp(arq+arqlen-2,".Z") == 0) {
- debuga(_("Decompressing log file \"%s\" with %s\n"),arq,"zcat");
+ debuga(__FILE__,__LINE__,_("Decompressing log file \"%s\" with %s\n"),arq,"zcat");
if (snprintf(cmd,sizeof(cmd),"zcat \"%s\"",arq)>=sizeof(cmd)) {
- debuga(_("decompression command too long for log file %s\n"),arq);
+ debuga(__FILE__,__LINE__,_("decompression command too long for log file %s\n"),arq);
exit(EXIT_FAILURE);
}
*pipe=true;
void denied_open(void)
{
if ((ReportType & REPORT_TYPE_DENIED) == 0) {
- if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced as it is not requested\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Denied report not produced as it is not requested\n"));
return;
}
if (Privacy) {
- if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced because privacy option is active\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Denied report not produced because privacy option is active\n"));
return;
}
snprintf(denied_unsort,sizeof(denied_unsort),"%s/denied.int_unsort",tmp);
if ((fp_denied=MY_FOPEN(denied_unsort,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),denied_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
return;
{
if (fp_denied) {
if (fclose(fp_denied)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),denied_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_denied=NULL;
if (!denied_exists) {
if (!KeepTempLog && denied_unsort[0]!='\0' && unlink(denied_unsort))
- debuga(_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
denied_unsort[0]='\0';
- if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced because it is empty\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Denied report not produced because it is empty\n"));
return;
}
if (debugz>=LogLevel_Process)
- debuga(_("Creating denied accesses report...\n"));
+ debuga(__FILE__,__LINE__,_("Creating denied accesses report...\n"));
if (snprintf(denied_sort,sizeof(denied_sort),"%s/denied.int_log",tmp)>=sizeof(denied_sort)) {
- debuga(_("Temporary directory path too long to sort the denied accesses\n"));
+ debuga(__FILE__,__LINE__,_("Temporary directory path too long to sort the denied accesses\n"));
exit(EXIT_FAILURE);
}
if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,denied_sort,denied_unsort)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),denied_unsort,denied_sort);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),denied_unsort,denied_sort);
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 (unlink(denied_unsort)) {
- debuga(_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
denied_unsort[0]='\0';
sprintf(report,"%s/denied.html",outdirname);
if((fp_in=MY_FOPEN(denied_sort,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),denied_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),denied_sort,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("USERID"),_("IP/NAME"),_("DATE/TIME"),_("ACCESSED SITE"));
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),denied_sort);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),denied_sort);
exit(EXIT_FAILURE);
}
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,'\t')<0 || getword(hora,sizeof(hora),&gwarea,'\t')<0 ||
getword(user,sizeof(user),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),denied_sort);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),denied_sort);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),denied_sort);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),denied_sort);
exit(EXIT_FAILURE);
}
if (sscanf(data,"%d/%d/%d",&day,&month,&year)!=3) continue;
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,denied_sort);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,denied_sort);
exit(EXIT_FAILURE);
}
fputs("</td></tr>\n",fp_ou);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),denied_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),denied_sort,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(denied_sort)==-1)
- debuga(_("Cannot delete \"%s\": %s\n"),denied_sort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),denied_sort,strerror(errno));
return;
}
{
if (fp_denied){
if (fclose(fp_denied)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),denied_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_denied=NULL;
}
if (!KeepTempLog && denied_unsort[0]) {
if (unlink(denied_unsort)==-1)
- debuga(_("Failed to delete \"%s\": %s\n"),denied_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),denied_unsort,strerror(errno));
}
}
Items=realloc(Obj->Items,Obj->NAllocated*sizeof(*Items));
if (!Items)
{
- debuga(_("Not enough memory to store the key/value pair %s/%s\n"),key,value);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the key/value pair %s/%s\n"),key,value);
exit(EXIT_FAILURE);
}
Obj->Items=Items;
Obj->Items[Position].Value=strdup(value);
if (!Obj->Items[Position].Key || !Obj->Items[Position].Value)
{
- debuga(_("Not enough memory to store the key/value pair %s/%s\n"),key,value);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the key/value pair %s/%s\n"),key,value);
exit(EXIT_FAILURE);
}
Obj->NItems++;
void download_open(void)
{
if ((ReportType & REPORT_TYPE_DOWNLOADS) == 0) {
- if (debugz>=LogLevel_Process) debugaz(_("Download report not produced as it is not requested\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Download report not produced as it is not requested\n"));
return;
}
if (Privacy) {
- if (debugz>=LogLevel_Process) debugaz(_("Download report not produced because privacy option is active\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Download report not produced because privacy option is active\n"));
return;
}
snprintf(download_unsort,sizeof(download_unsort),"%s/download.int_unsort",tmp);
if ((fp_download=MY_FOPEN(download_unsort,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),download_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
return;
if (fp_download)
{
if (fclose(fp_download)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),download_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_download=NULL;
clen=snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o \"%s\" \"%s\"",
tmp, report_in, download_unsort);
if (clen>=sizeof(csort)) {
- debuga(_("Path too long to sort file \"%s\"\n"),download_unsort);
+ debuga(__FILE__,__LINE__,_("Path too long to sort file \"%s\"\n"),download_unsort);
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 (!KeepTempLog) {
if (unlink(download_unsort)) {
- debuga(_("Cannot delete \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),download_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
download_unsort[0]='\0';
if (!download_exists) {
if (!KeepTempLog && download_unsort[0]!='\0' && unlink(download_unsort))
- debuga(_("Cannot delete \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),download_unsort,strerror(errno));
download_unsort[0]='\0';
- if (debugz>=LogLevel_Process) debugaz(_("No downloaded files to report\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("No downloaded files to report\n"));
return;
}
if (debugz>=LogLevel_Process)
- debuga(_("Creating download report...\n"));
+ debuga(__FILE__,__LINE__,_("Creating download report...\n"));
ouser[0]='\0';
ouser2[0]='\0';
snprintf(report,sizeof(report),"%s/download.html",outdirname);
if((fp_in=MY_FOPEN(report_in,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report_in,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("USERID"),_("IP/NAME"),_("DATE/TIME"),_("ACCESSED SITE"));
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),report_in);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),report_in);
exit(EXIT_FAILURE);
}
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,'\t')<0 || getword(hora,sizeof(hora),&gwarea,'\t')<0 ||
getword(user,sizeof(user),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),report_in);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),report_in);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),report_in);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),report_in);
exit(EXIT_FAILURE);
}
if (sscanf(data,"%d/%d/%d",&day,&month,&year)!=3) continue;
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,report_in);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,report_in);
exit(EXIT_FAILURE);
}
new_user=false;
fputs("</td></tr>\n",fp_ou);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),report_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),report_in,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(report_in)) {
- debuga(_("Cannot delete \"%s\": %s\n"),report_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),report_in,strerror(errno));
exit(EXIT_FAILURE);
}
DownloadSuffix=strdup(list);
if (!DownloadSuffix) {
- debuga(_("Download suffix list too long\n"));
+ debuga(__FILE__,__LINE__,_("Download suffix list too long\n"));
exit(EXIT_FAILURE);
}
j = 1;
if (list[i] == ',') j++;
DownloadSuffixIndex=malloc(j*sizeof(char *));
if (!DownloadSuffixIndex) {
- debuga(_("Too many download suffixes\n"));
+ debuga(__FILE__,__LINE__,_("Too many download suffixes\n"));
exit(EXIT_FAILURE);
}
{
if (fp_download) {
if (fclose(fp_download)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),download_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
fp_download=NULL;
}
if (download_unsort[0]) {
if (unlink(download_unsort)==-1)
- debuga(_("Failed to delete \"%s\": %s\n"),download_unsort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),download_unsort,strerror(errno));
}
}
snprintf(wger,sizeof(wger),"%s/sarg-general",dirname);
if((fp_in=fopen(wger,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(top2,sizeof(top2),"%s/top.tmp",dirname);
if((fp_top2=fopen(top2,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
totuser=0;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),wger);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wger);
exit(EXIT_FAILURE);
}
tnelap+=item.nelap;
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wger,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
}
if (fclose(fp_top2)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (ttnacc!=globstat.nacc || ttnbytes!=globstat.nbytes || ttnelap!=globstat.elap) {
- debuga(_("Total statistics mismatch when reading \"%s\" to produce the email report\n"),wger);
+ debuga(__FILE__,__LINE__,_("Total statistics mismatch when reading \"%s\" to produce the email report\n"),wger);
exit(EXIT_FAILURE);
}
#endif
if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
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 (!KeepTempLog && unlink(top2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_top1=fopen(top1,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(warea);
getword_start(&gwarea,warea);
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("Invalid user ID in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid user ID in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
- debuga(_("Invalid number of bytes in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nacc,&gwarea,'\t')<0) {
- debuga(_("Invalid number of accesses in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&elap,&gwarea,'\0')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,top1);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,top1);
exit(EXIT_FAILURE);
}
#endif
if (fclose(fp_top1)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(top1)) {
- debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_top3, "\n%s\n", asctime(local));
if (fclose(fp_top3)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
if(strcmp(email,"stdout") == 0) {
if((fp_top3=fopen(top3,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
fputs(warea,stdout);
if (fclose(fp_top3)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
} else {
strftime(Subject,sizeof(Subject),_("SARG report, %c"),local);
snprintf(warea,sizeof(warea),"%s -s \"%s\" \"%s\" <\"%s\"",MailUtility,Subject,email,top3);
if (debug)
- debuga(_("Sending mail with command: %s\n"),warea);
+ debuga(__FILE__,__LINE__,_("Sending mail with command: %s\n"),warea);
cstatus=system(warea);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("command: %s\n"),warea);
+ debuga(__FILE__,__LINE__,_("command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("command: %s\n"),warea);
exit(EXIT_FAILURE);
}
}
ip4allocated+=5;
temp=realloc(exclude_ip4,ip4allocated*sizeof(*temp));
if (temp==NULL) {
- debuga(_("Not enough memory to store the exlcluded IP addresses\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the exlcluded IP addresses\n"));
exit(EXIT_FAILURE);
}
exclude_ip4=temp;
ip6allocated+=5;
temp=realloc(exclude_ip6,ip6allocated*sizeof(*temp));
if (temp==NULL) {
- debuga(_("Not enough memory to store the exlcluded IP addresses\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the exlcluded IP addresses\n"));
exit(EXIT_FAILURE);
}
exclude_ip6=temp;
nameallocated+=5;
temp=realloc(exclude_name,nameallocated*sizeof(*temp));
if (temp==NULL) {
- debuga(_("Not enough memory to store the excluded URLs\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the excluded URLs\n"));
exit(EXIT_FAILURE);
}
exclude_name=temp;
num_exclude_name++;
item->url=malloc(length+1);
if (!item->url) {
- debuga(_("Not enough memory to store the excluded URLs\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the excluded URLs\n"));
exit(EXIT_FAILURE);
}
safe_strcpy(item->url,url,length+1);
const char *next;
if(access(hexfile, R_OK) != 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug)
- debuga(_("Loading exclude host file from \"%s\"\n"),hexfile);
+ debuga(__FILE__,__LINE__,_("Loading exclude host file from \"%s\"\n"),hexfile);
if ((fp_ex = fopen(hexfile, "r")) == NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
exit(EXIT_FAILURE);
}
type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next);
if (type<0) {
- debuga(_("While reading \"%s\"\n"),hexfile);
+ debuga(__FILE__,__LINE__,_("While reading \"%s\"\n"),hexfile);
exit(EXIT_FAILURE);
}
}
if (fclose(fp_ex)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),hexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),hexfile,strerror(errno));
exit(EXIT_FAILURE);
}
return;
long int nreg=0;
if(debug)
- debuga(_("Loading exclude file from \"%s\"\n"),uexfile);
+ debuga(__FILE__,__LINE__,_("Loading exclude file from \"%s\"\n"),uexfile);
if ((fp_ex = fopen(uexfile, "r")) == NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),uexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),uexfile,strerror(errno));
exit(EXIT_FAILURE);
}
if (fseek(fp_ex, 0, SEEK_END)==-1) {
- debuga(_("Failed to move till the end of file \"%s\": %s\n"),uexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to move till the end of file \"%s\": %s\n"),uexfile,strerror(errno));
exit(EXIT_FAILURE);
}
nreg = ftell(fp_ex);
if (nreg<0) {
- debuga(_("Cannot get the size of file \"%s\"\n"),uexfile);
+ debuga(__FILE__,__LINE__,_("Cannot get the size of file \"%s\"\n"),uexfile);
exit(EXIT_FAILURE);
}
nreg += 11;
if (fseek(fp_ex, 0, SEEK_SET)==-1) {
- debuga(_("Failed to rewind file \"%s\": %s\n"),uexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to rewind file \"%s\": %s\n"),uexfile,strerror(errno));
exit(EXIT_FAILURE);
}
if((excludeuser=(char *) malloc(nreg))==NULL){
- debuga(_("malloc error (%ld bytes required)\n"),nreg);
+ debuga(__FILE__,__LINE__,_("malloc error (%ld bytes required)\n"),nreg);
exit(EXIT_FAILURE);
}
strcat(excludeuser,"*END* ");
if (fclose(fp_ex)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),uexfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),uexfile,strerror(errno));
exit(EXIT_FAILURE);
}
while (*buf && (unsigned char)*buf<=' ') buf++;
if (strlen(buf)>=value_size) {
- debuga(_("The string value of parameter \"%s\" is too long\n"),param);
+ debuga(__FILE__,__LINE__,_("The string value of parameter \"%s\" is too long\n"),param);
exit(EXIT_FAILURE);
}
strcpy(value,buf);
while (*buf && (unsigned char)*buf<=' ') buf++;
if (*buf != '\"') {
- debuga(_("Missing double quote after parameter \"%s\"\n"),param);
+ debuga(__FILE__,__LINE__,_("Missing double quote after parameter \"%s\"\n"),param);
exit(EXIT_FAILURE);
}
buf++;
value[i]='\0';
if (*buf != '\"') {
- debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
+ debuga(__FILE__,__LINE__,_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
exit(EXIT_FAILURE);
}
fixnone(value);
for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
word1[i]=*buf++;
if (i>=word1_size) {
- debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
+ debuga(__FILE__,__LINE__,_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
exit(EXIT_FAILURE);
}
if (*buf!=' ') {
- debuga(_("Missing second word for parameter \"%s\"\n"),param);
+ debuga(__FILE__,__LINE__,_("Missing second word for parameter \"%s\"\n"),param);
exit(EXIT_FAILURE);
}
word1[i]=0;
for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
word2[i]=*buf++;
if (i>=word2_size) {
- debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
+ debuga(__FILE__,__LINE__,_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
exit(EXIT_FAILURE);
}
word2[i]=0;
next=0;
if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
- debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
+ debuga(__FILE__,__LINE__,_("The integer value of parameter \"%s\" is invalid\n"),param);
exit(EXIT_FAILURE);
}
return(1);
}
for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
if (i>=noptions) {
- debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
+ debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE);
}
if ((*value & options[i].exclude)!=0) {
- debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
+ debuga(__FILE__,__LINE__,_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE);
}
*value|=options[i].value;
}
for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
if (i>=noptions) {
- debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
+ debuga(__FILE__,__LINE__,_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE);
}
*value=options[i].value;
if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) {
*value|=SORT_REVERSE;
} else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) {
- debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param);
+ debuga(__FILE__,__LINE__,_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param);
exit(EXIT_FAILURE);
}
}
*buf='\0';
for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++);
if (i>=noptions) {
- debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param);
+ debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param);
exit(EXIT_FAILURE);
}
*value=options[i].value;
do {
while (*buf && (unsigned char)*buf>' ') buf++;
if (*buf!=' ') {
- debuga(_("Missing limit in per_user_limit\n"));
+ debuga(__FILE__,__LINE__,_("Missing limit in per_user_limit\n"));
exit(EXIT_FAILURE);
}
file_end=buf;
break;
}
if (i<0) {
- debuga(_("Invalid output type in per_user_limit\n"));
+ debuga(__FILE__,__LINE__,_("Invalid output type in per_user_limit\n"));
exit(EXIT_FAILURE);
}
}
if (PerUserLimitsNumber>=MAX_USER_LIMITS) {
- debuga(_("Too many per_user_limit\n"));
+ debuga(__FILE__,__LINE__,_("Too many per_user_limit\n"));
exit(EXIT_FAILURE);
}
*file_end='\0';
if (is_param("date_format",buf)) {
getword_start(&gwarea,buf);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
- debuga(_("Invalid record in \"date_format\" parameter\n"));
+ debuga(__FILE__,__LINE__,_("Invalid record in \"date_format\" parameter\n"));
exit(EXIT_FAILURE);
}
DateFormat=gwarea.current[0];
if (is_param("hours",buf)) {
if( getnumlist( buf, &hours, 24, 24 ) ) {
- debuga(_("Error: Invalid syntax in hours tag!\n"));
+ debuga(__FILE__,__LINE__,_("Error: Invalid syntax in hours tag!\n"));
exit( 1 );
}
return;
if (is_param("weekdays",buf)) {
if( getnumlist( buf, &weekdays, 7, 7 ) ) {
- debuga(_("Error: Invalid syntax in weekdays tag!\n"));
+ debuga(__FILE__,__LINE__,_("Error: Invalid syntax in weekdays tag!\n"));
exit( 1 );
}
return;
if (!AccessLog)
AccessLog=FileList_Create();
if (!FileList_AddFile(AccessLog,FileName)) {
- debuga(_("Not enough memory to store the input log file names\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the input log file names\n"));
exit(EXIT_FAILURE);
}
}
if (is_param("redirector_log",buf)>0) {
if (RedirectorLogFromCmdLine==0) {
if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
- debuga(_("Too many redirector log files in configuration file\n"));
+ debuga(__FILE__,__LINE__,_("Too many redirector log files in configuration file\n"));
exit(EXIT_FAILURE);
}
getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN);
if (is_absolute(wbuf)) {
if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
- debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
+ debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
exit(EXIT_FAILURE);
}
safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemplateFile));
} else {
safe_strcpy(dir,ConfigFile,sizeof(dir));
if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
- debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
+ debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
exit(EXIT_FAILURE);
}
}
if (getparam_bool("graphs",buf,&Graphs)>0) {
#ifndef HAVE_GD
if (Graphs)
- debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"),
+ debugaz(__FILE__,__LINE__,_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"),
ConfigFile);
#endif
return;
if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return;
if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) {
- debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
+ debuga(__FILE__,__LINE__,_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
return;
}
/*
Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name.
*/
- debuga(_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configuration file.\n"));
+ debuga(__FILE__,__LINE__,_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configuration file.\n"));
RedirectorFilterOutDate=!RedirectorFilterOutDate;
return;
}
if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) {
- debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configuration file.\n"));
+ debuga(__FILE__,__LINE__,_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configuration file.\n"));
RedirectorFilterOutDate=!RedirectorFilterOutDate;
return;
}
if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return;
if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) {
- debuga(_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n"));
+ debuga(__FILE__,__LINE__,_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n"));
DansguardianFilterOutDate=!DansguardianFilterOutDate;
return;
}
if(strstr(buf,"byte_cost") != 0) {
getword_start(&gwarea,buf);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
- debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
+ debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
exit(EXIT_FAILURE);
}
cost=atol(gwarea.current);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
- debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
+ debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
exit(EXIT_FAILURE);
}
nocost=my_atoll(gwarea.current);
char buf[MAXLEN];
if(debug)
- debuga(_("Loading configuration from \"%s\"\n"),ConfigFile);
+ debuga(__FILE__,__LINE__,_("Loading configuration from \"%s\"\n"),ConfigFile);
if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno));
exit(EXIT_FAILURE);
}
return;
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(_("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 yscale;
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);
}
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)) {
/* TRANSLATORS: The message is followed by the path that is too long. */
- debuga(_("User name too long to manufacture file name "));
+ 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(_("Cannot open file \"%s\": %s\n"),graph,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),graph,strerror(errno));
exit(EXIT_FAILURE);
}
gdImagePng(gdata.im, pngout);
if (fclose(pngout)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),graph,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),graph,strerror(errno));
}
gdImageDestroy(gdata.im);
#ifdef HAVE_GD
if (!Graphs) {
if (debugz>=LogLevel_Process)
- debugaz(_("Graphs disabled as requested in %s\n"),ConfigFile);
+ debugaz(__FILE__,__LINE__,_("Graphs disabled as requested in %s\n"),ConfigFile);
return;
}
if (GraphFont[0]=='\0') {
if (debugz>=LogLevel_Process)
- debugaz(_("Graphs disabled as no font names were provided in %s\n"),ConfigFile);
+ debugaz(__FILE__,__LINE__,_("Graphs disabled as no font names were provided in %s\n"),ConfigFile);
return;
}
if(access(GraphFont, R_OK) != 0) {
- debuga(_("Font name %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(_("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
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 to manufacture file name "));
+ debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
debuga_more("%s/%s.day\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
}
if((fp_in=fopen(wdirname,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ 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) {
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;
}
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
+ 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 to manufacture file name "));
+ 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(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ 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);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
#endif //HAVE_GD
userscan uscan;
if (snprintf(tmp2,sizeof(tmp2),"%s/sargtmp.int_unsort",tmp)>=sizeof(tmp2)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sargtmp.int_unsort\n",tmp);
exit(EXIT_FAILURE);
}
if (snprintf(tmp3,sizeof(tmp3),"%s/sargtmp.int_log",tmp)>=sizeof(tmp3)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sargtmp.int_log\n",tmp);
exit(EXIT_FAILURE);
}
for (i=0 ; i<PerUserLimitsNumber ; i++) {
FILE *fp_usr=fopen(PerUserLimits[i].File,"wt");
if (fp_usr==NULL) {
- debuga(_("Cannot create empty per_user_limit file \"%s\": %s\n"),PerUserLimits[i].File,
+ debuga(__FILE__,__LINE__,_("Cannot create empty per_user_limit file \"%s\": %s\n"),PerUserLimits[i].File,
strerror(errno));
exit(EXIT_FAILURE);
}
if (fclose(fp_usr)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
exit(EXIT_FAILURE);
}
}
case PUFC_AsRequired:
for (i=0 ; i<PerUserLimitsNumber ; i++) {
if (access(PerUserLimits[i].File,R_OK)==0 && unlink(PerUserLimits[i].File)==-1) {
- debuga(_("Cannot delete \"%s\": %s\n"),PerUserLimits[i].File,
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),PerUserLimits[i].File,
strerror(errno));
exit(EXIT_FAILURE);
}
uscan=userinfo_startscan();
if (uscan == NULL) {
- debuga(_("Cannot enumerate the user list\n"));
+ debuga(__FILE__,__LINE__,_("Cannot enumerate the user list\n"));
exit(EXIT_FAILURE);
}
while ( (uinfo = userinfo_advancescan(uscan)) != NULL ) {
if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,uinfo->filename)>=sizeof(warea)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",outdirname,uinfo->filename);
exit(EXIT_FAILURE);
}
if (access(warea, R_OK) != 0) {
if (PortableMkDir(warea,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),warea,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),warea,strerror(errno));
exit(EXIT_FAILURE);
}
}
tmpsort(uinfo);
if (snprintf(arqin,sizeof(arqin),"%s/htmlrel.txt",tmp)>=sizeof(arqin)) {
- debuga(_("Input file name too long: %s/htmlrel.txt\n"),tmp);
+ debuga(__FILE__,__LINE__,_("Input file name too long: %s/htmlrel.txt\n"),tmp);
exit(EXIT_FAILURE);
}
if ((fp_in = fopen(arqin, "r")) == 0){
if (uinfo->no_report) continue;
- debuga(_("Cannot open file \"%s\": %s\n"),arqin,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqin,strerror(errno));
exit(EXIT_FAILURE);
}
if (snprintf(arqou,sizeof(arqou),"%s/%s/%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqou)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s/%s.html\n",outdirname,uinfo->filename,uinfo->filename);
exit(EXIT_FAILURE);
}
if (snprintf(duser,sizeof(duser),"%s/denied_%s.html",outdirname,uinfo->filename)>=sizeof(duser)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/denied_%s.html\n",outdirname,uinfo->filename);
exit(EXIT_FAILURE);
}
have_denied_report=true;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword_atoll(<emp,&gwarea,'\t')<0) {
- debuga(_("Invalid number of accesses in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
tnacc+=ltemp;
if (getword_atoll(<emp,&gwarea,'\t')<0) {
- debuga(_("Invalid downloaded size in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid downloaded size in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
tnbytes+=ltemp;
if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_skip(MAXLEN,&gwarea,'\t')<0) {
- debuga(_("Invalid access code in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid access code in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_atoll(<emp,&gwarea,'\t')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
tnelap+=ltemp;
if (getword_atoll(<emp,&gwarea,'\t')<0) {
- debuga(_("Invalid in-cache size in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid in-cache size in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
tnincache+=ltemp;
if (getword_atoll(<emp,&gwarea,'\n')<0) {
- debuga(_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
tnoucache+=ltemp;
rewind(fp_in);
if ((fp_ou = fopen(arqou, "w")) == 0){
- debuga(_("Cannot open file \"%s\": %s\n"),arqou,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqou,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</tr></thead>\n",fp_ou);
if(debug) {
- debuga(_("Making report %s\n"),uinfo->id);
+ debuga(__FILE__,__LINE__,_("Making report %s\n"),uinfo->id);
}
count=0;
arqip[0]='\0';
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword_atoll(&twork,&gwarea,'\t')<0) {
- debuga(_("Invalid number of accesses in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nnbytes,&gwarea,'\t')<0) {
- debuga(_("Invalid number of bytes in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword(tmsg,sizeof(tmsg),&gwarea,'\t')<0) {
- debuga(_("Invalid access code in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid access code in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nnelap,&gwarea,'\t')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_atoll(&incache,&gwarea,'\t')<0) {
- debuga(_("Invalid in-cache size in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid in-cache size in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
if (getword_atoll(&oucache,&gwarea,'\n')<0) {
- debuga(_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
exit(EXIT_FAILURE);
}
} else if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
snprintf(warea,sizeof(warea),"%s/%s/tt.html",outdirname,uinfo->filename);
if (unlink(warea)!=0) {
- debuga(_("Cannot delete \"%s\": %s\n"),warea,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),warea,strerror(errno));
}
}
if(iprel) {
if (snprintf(arqip,sizeof(arqip),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(arqip)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.ip\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if ((fp_ip = fopen(arqip, "r")) == 0){
- debuga(_("Cannot open file \"%s\": %s\n"),arqip,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqip,strerror(errno));
exit(EXIT_FAILURE);
}
if ((fp_ip2 = MY_FOPEN(tmp2, "a")) == 0){
- 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);
}
if ((line1=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arqip);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqip);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_ip,line1))!=NULL) {
getword_start(&gwarea,buf);
if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
- debuga(_("Invalid user IP in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid user IP in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&user_url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (strncmp(user_url,url,strlen(url))!=0) continue;
if (getword_skip(15,&gwarea,'\t')<0) {
- debuga(_("Invalid day in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid day in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_skip(15,&gwarea,'\t')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
- debuga(_("Invalid size in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid size in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_atoll(&userelap,&gwarea,'\0')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
fprintf(fp_ip2,"%s\t%"PRIu64"\t%"PRIu64"\n",user_ip,(uint64_t)userbytes,(uint64_t)userelap);
longline_destroy(&line1);
if (fclose(fp_ip2)==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_ip)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),arqip,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arqip,strerror(errno));
exit(EXIT_FAILURE);
}
if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,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_ip = MY_FOPEN(tmp3, "r")) == 0) {
- 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 (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);
}
olduserip[0]='\0';
if ((line1=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arqip);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqip);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_ip,line1))!=NULL) {
getword_start(&gwarea,buf);
if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
- debuga(_("Invalid user IP in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid user IP in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
- debuga(_("Invalid size in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid size in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_atoll(&userelap,&gwarea,'\0')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if(strcmp(user_ip,olduserip) != 0) {
}
if (fclose(fp_ip)==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);
}
longline_destroy(&line1);
if (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 (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),arqin,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arqin,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
if (iprel && arqip[0]) {
if (!KeepTempLog && unlink(arqip)) {
- debuga(_("Cannot delete \"%s\": %s\n"),arqip,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqip,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (!KeepTempLog && unlink(arqin)) {
- debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
exit(EXIT_FAILURE);
}
FILE *fp_usr;
if((fp_usr = fopen(PerUserLimits[i].File, "at")) == 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
exit(EXIT_FAILURE);
}
switch (PerUserLimits[i].Output)
break;
}
if (fclose(fp_usr)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
exit(EXIT_FAILURE);
}
user_limit[maskid]|=mask;
if(debug)
- debuga(_("Limit exceeded for user %s (%d MB). Added to file \"%s\"\n"),uinfo->label,
+ debuga(__FILE__,__LINE__,_("Limit exceeded for user %s (%d MB). Added to file \"%s\"\n"),uinfo->label,
PerUserLimits[i].Limit,PerUserLimits[i].File);
}
}
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),arqou,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqou,strerror(errno));
exit(EXIT_FAILURE);
}
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 debuga(const char *File, int Line, const char *msg,...) __attribute__((format(printf,3,4)));
void debuga_more(const char *msg,...) __attribute__((format(printf,1,2)));
-void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
+void debugaz(const char *File,int Line,const char *msg,...) __attribute__((format(printf,3,4)));
void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
void url_module(const char *url, char *w2);
void url_to_anchor(const char *url,char *anchor,int size);
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. File name is \"%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 \"%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);
}
}
char remove[MAXLEN];
if ((dirp = opendir(dirname)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),dirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),dirname,strerror(errno));
exit(EXIT_FAILURE);
}
while ( (direntp = readdir( dirp )) != NULL ){
continue;
if (snprintf(remove,sizeof(remove),"%s/%s",dirname,direntp->d_name)>=sizeof(remove)) {
- debuga(_("Name of the file to remove is too long. File name is \"%s/%s\"\n"),dirname,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Name of the file to remove is too long. File name is \"%s/%s\"\n"),dirname,direntp->d_name);
continue;
}
if (unlink(remove) == -1) {
- debuga(_("Cannot delete \"%s\": %s\n"),remove,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),remove,strerror(errno));
}
}
struct Ip2NameProcess *Chain;
struct Ip2NameProcess *Last;
- if (debug) debuga(_("Chaining IP resolving module \"%s\"\n"),Module->Name);
+ if (debug) debuga(__FILE__,__LINE__,_("Chaining IP resolving module \"%s\"\n"),Module->Name);
Last=NULL;
for (Chain=FirstModule ; Chain ; Chain=Chain->Next) {
if (Chain==Module) {
- debuga(_("Ignoring duplicate module \"%s\" to resolve an IP address\n"),Module->Name);
+ debuga(__FILE__,__LINE__,_("Ignoring duplicate module \"%s\" to resolve an IP address\n"),Module->Name);
return;
}
Last=Chain;
}
}
if (ModuleIdx>=sizeof(ModulesList)/sizeof(*ModulesList)) {
- debuga(_("Unknown module \"%.*s\" to resolve the IP addresses\n"),length,candidate);
+ debuga(__FILE__,__LINE__,_("Unknown module \"%.*s\" to resolve the IP addresses\n"),length,candidate);
exit(EXIT_FAILURE);
}
list=candidate+length;
// module found
if (ModulesList[ModuleIdx].Process) {
if (!ModulesList[ModuleIdx].Process->Configure) {
- debuga(_("No option to configure for module %s\n"),ModulesList[ModuleIdx].Name);
+ debuga(__FILE__,__LINE__,_("No option to configure for module %s\n"),ModulesList[ModuleIdx].Name);
exit(EXIT_FAILURE);
}
while (module[length] && (unsigned char)module[length]<=' ') length++;
}
}
if (!DnsModule) {
- if (debugz>=LogLevel_Process) debuga(_("No known module to resolve an IP address using the DNS\n"));
+ if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("No known module to resolve an IP address using the DNS\n"));
exit(EXIT_FAILURE);
}
for (Chain=FirstModule ; Chain && Chain!=DnsModule ; Chain=Chain->Next) {
Last=Chain;
}
- if (debug) debuga(_("Chaining IP resolving module \"%s\"\n"),DnsModule->Name);
+ if (debug) debuga(__FILE__,__LINE__,_("Chaining IP resolving module \"%s\"\n"),DnsModule->Name);
if (Last)
Last->Next=DnsModule;
else {
if (!KnownIp) {
KnownIp=Dichotomic_Create();
if (!KnownIp) {
- debuga(_("Not enough memory to store the names corresponding to the IP address\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the names corresponding to the IP address\n"));
exit(EXIT_FAILURE);
}
}
error=getaddrinfo(addr,NULL,NULL,&res);
if (error) {
freeaddrinfo(res);
- debuga(_("Cannot resolve host name %s: %s\n"),name,gai_strerror(error));
+ debuga(__FILE__,__LINE__,_("Cannot resolve host name %s: %s\n"),name,gai_strerror(error));
exit(EXIT_FAILURE);
}
if (res->ai_family==AF_INET) {
struct sockaddr_in *s4=(struct sockaddr_in *)res->ai_addr;
struct in_addr *sa=&s4->sin_addr;
if (res->ai_addrlen<sizeof(*s4)) {
- debuga(_("Short structure returned by getaddrinfo for an IPv4 address: %d bytes instead of %d\n"),res->ai_addrlen,(int)sizeof(*s4));
+ debuga(__FILE__,__LINE__,_("Short structure returned by getaddrinfo for an IPv4 address: %d bytes instead of %d\n"),res->ai_addrlen,(int)sizeof(*s4));
exit(EXIT_FAILURE);
}
inet_ntop(res->ai_family,sa,name,name_size);
struct sockaddr_in6 *s6=(struct sockaddr_in6 *)res->ai_addr;
struct in6_addr *sa6=&s6->sin6_addr;
if (res->ai_addrlen<sizeof(*s6)) {
- debuga(_("Short structure returned by getaddrinfo for an IPv6 address: %d bytes instead of %d\n"),res->ai_addrlen,(int)sizeof(*s6));
+ debuga(__FILE__,__LINE__,_("Short structure returned by getaddrinfo for an IPv6 address: %d bytes instead of %d\n"),res->ai_addrlen,(int)sizeof(*s6));
exit(EXIT_FAILURE);
}
inet_ntop(res->ai_family,sa6,name,name_size);
} else {
- debuga(_("Invalid address type %d returned when resolving host name \"%s\"\n"),res->ai_family,name);
+ debuga(__FILE__,__LINE__,_("Invalid address type %d returned when resolving host name \"%s\"\n"),res->ai_family,name);
}
freeaddrinfo(res);
#else
getword_start(&gwarea,inet_ntoa(ia));
if (getword(n4,sizeof(n4),&gwarea,'.')<0 || getword(n3,sizeof(n3),&gwarea,'.')<0 ||
getword(n2,sizeof(n2),&gwarea,'.')<0 || getword(n1,sizeof(n1),&gwarea,0)<0) {
- debuga(_("Invalid IPv4 address \"%s\"\n"),gwarea.beginning);
+ debuga(__FILE__,__LINE__,_("Invalid IPv4 address \"%s\"\n"),gwarea.beginning);
exit(EXIT_FAILURE);
}
snprintf(name,name_size,"%s.%s.%s.%s",n1,n2,n3,n4);
if (error==EAI_NONAME)
return(INRC_NotFound);
if (error!=0) {
- debuga(_("IP to name resolution (getnameinfo) on IP address \"%s\" failed with error %d - %s\n"),ip,error,gai_strerror(error));
+ debuga(__FILE__,__LINE__,_("IP to name resolution (getnameinfo) on IP address \"%s\" failed with error %d - %s\n"),ip,error,gai_strerror(error));
return(INRC_Error);
}
safe_strcpy(ip,host,ip_len);
len=strlen(param);
if (len>=sizeof(ExecCmd)) {
- debuga(_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
+ debuga(__FILE__,__LINE__,_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
exit(EXIT_FAILURE);
}
strcpy(ExecCmd,param);
size_t nread;
if (ExecCmd[0]=='\0') {
- debuga(_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
+ debuga(__FILE__,__LINE__,_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
exit(EXIT_FAILURE);
}
for (i=0 ; i<sizeof(ExecCmd) && ExecCmd[i] ; i++) {
if (ExecCmd[i]=='%' && strncmp(ExecCmd+i+1,"IP",2)==0) {
if (j+len>=sizeof(cmd)) {
- debuga(_("IP address \"%s\" too long for the command to run\n"),ip);
+ debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error);
}
strcpy(cmd+j,ip);
i+=2;
} else {
if (j>=sizeof(cmd)) {
- debuga(_("IP address \"%s\" too long for the command to run\n"),ip);
+ debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error);
}
cmd[j++]=ExecCmd[i];
cmd_in=popen(cmd,"r");
if (!cmd_in) {
- debuga(_("Cannot run command %s\n"),cmd);
+ debuga(__FILE__,__LINE__,_("Cannot run command %s\n"),cmd);
exit(EXIT_FAILURE);
}
nread=fread(buffer,1,sizeof(buffer),cmd_in);
if (pclose(cmd_in)==-1) {
- debuga(_("Command failed: %s\n"),cmd);
+ debuga(__FILE__,__LINE__,_("Command failed: %s\n"),cmd);
exit(EXIT_FAILURE);
}
entry=malloc(sizeof(*entry));
if (!entry) {
- debuga(_("Not enough memory to store a report to purge\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store a report to purge\n"));
DeleteDirList(List);
return(NULL);
}
entry->Name=malloc((NameLen+1)*sizeof(char));
if (!entry->Name) {
free(entry);
- debuga(_("Not enough memory to store a report to purge\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store a report to purge\n"));
DeleteDirList(List);
return(NULL);
}
int name_len;
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);
}
while ((direntp = readdir( dirp )) != NULL )
{
name_len=strlen(direntp->d_name);
if (RootPos+name_len+1>=PathSize) {
- debuga(_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
exit(EXIT_FAILURE);
}
strcpy(Path+Length,direntp->d_name);
if (stat(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)) continue;
List=BuildDirDateList(List,Path,PathSize,RootPos,Length+name_len+1,1);
if (!List)
{
- debuga(_("Old reports deletion not undertaken due to previous error\n"));
+ debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
break;
}
}
List=AppendDirEntry(List,statb.st_mtime,Path+RootPos,Length-RootPos+name_len);
if (!List)
{
- debuga(_("Old reports deletion not undertaken due to previous error\n"));
+ debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
break;
}
}
name_pos=strlen(Path);
if (name_pos>=sizeof(warea)) {
- debuga(_("The directory name \"%s\" containing the old reports to purge is too long\n"),Path);
+ debuga(__FILE__,__LINE__,_("The directory name \"%s\" containing the old reports to purge is too long\n"),Path);
exit(EXIT_FAILURE);
}
strcpy(warea,Path);
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 )
{
name_len=strlen(direntp->d_name);
if (name_pos+name_len+1>=sizeof(warea)) {
- debuga(_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
exit(EXIT_FAILURE);
}
strcpy(warea+name_pos,direntp->d_name);
if (stat(warea,&statb) == -1) {
- debuga(_("Failed to get the statistics of file \"%s\": %s\n"),warea,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),warea,strerror(errno));
continue;
}
if (!S_ISDIR(statb.st_mode)) continue;
List=AppendDirEntry(List,statb.st_mtime,direntp->d_name,name_len);
if (!List)
{
- debuga(_("Old reports deletion not undertaken due to previous error\n"));
+ debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
break;
}
}
List=BuildDirDateList(List,warea,sizeof(warea),name_pos,name_pos+name_len+1,0);
if (!List)
{
- debuga(_("Old reports deletion not undertaken due to previous error\n"));
+ debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
break;
}
}
if (Dir-Path<=BasePos) break;
*Dir='\0';
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));
return;
}
index=false;
break;
}
if (debug)
- debuga(_("Deleting empty directory \"%s\"\n"),Path);
+ debuga(__FILE__,__LINE__,_("Deleting empty directory \"%s\"\n"),Path);
if (index) {
if (strlen(Path)+strlen(INDEX_HTML_FILE)+2>=PathSize) {
- debuga(_("Buffer too small to delete index file \"%s/%s\""),Path,INDEX_HTML_FILE);
+ debuga(__FILE__,__LINE__,_("Buffer too small to delete index file \"%s/%s\""),Path,INDEX_HTML_FILE);
exit(EXIT_FAILURE);
}
strcat(Path,"/"INDEX_HTML_FILE);
if (unlink(Path)==-1) {
- debuga(_("Failed to delete \"%s\": %s\n"),Path,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),Path,strerror(errno));
exit(EXIT_FAILURE);
}
*Dir='\0';
}
if (rmdir(Path)) {
- debuga(_("Cannot delete \"%s\": %s\n"),Path,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),Path,strerror(errno));
exit(EXIT_FAILURE);
}
}
for (ptr=List ; ptr ; ptr=ptr->Next) ftot++;
if (debug)
- debuga(ngettext("%d report directory found\n","%d report directories found\n",ftot),ftot);
+ debuga(__FILE__,__LINE__,ngettext("%d report directory found\n","%d report directories found\n",ftot),ftot);
if(ftot<=LastLog) {
DeleteDirList(List);
if (debug) {
- debuga(ngettext("No old reports to delete as only %d report currently exists\n",
+ debuga(__FILE__,__LINE__,ngettext("No old reports to delete as only %d report currently exists\n",
"No old reports to delete as only %d reports currently exist\n",ftot),ftot);
}
return;
ftot-=LastLog;
if (debug)
- debuga(ngettext("%d old report to delete\n","%d old reports to delete\n",ftot),ftot);
+ debuga(__FILE__,__LINE__,ngettext("%d old report to delete\n","%d old reports to delete\n",ftot),ftot);
name_pos=strlen(outdir);
if (name_pos>=sizeof(warea)) {
DeleteDirList(List);
- debuga(_("The directory name \"%s\" containing the old reports to purge is too long\n"),outdir);
+ debuga(__FILE__,__LINE__,_("The directory name \"%s\" containing the old reports to purge is too long\n"),outdir);
exit(EXIT_FAILURE);
}
strcpy(warea,outdir);
for (ptr=List ; ptr && ftot>0 ; ptr=ptr->Next)
{
if(debug)
- debuga(_("Removing old report file %s\n"),ptr->Name);
+ debuga(__FILE__,__LINE__,_("Removing old report file %s\n"),ptr->Name);
if (name_pos+strlen(ptr->Name)+1>=sizeof(warea)) {
DeleteDirList(List);
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s\n",outdir,ptr->Name);
exit(EXIT_FAILURE);
}
if (!AccessLog)
AccessLog=FileList_Create();
if (!FileList_AddFile(AccessLog,optarg)) {
- debuga(_("Not enough memory to store the input log file names\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the input log file names\n"));
exit(EXIT_FAILURE);
}
AccessLogFromCmdLine++;
break;
case 'L':
if (NRedirectorLogs>MAX_REDIRECTOR_LOGS) {
- debuga(_("Too many redirector logs passed on command line with option -L.\n"));
+ debuga(__FILE__,__LINE__,_("Too many redirector logs passed on command line with option -L.\n"));
exit(EXIT_FAILURE);
}
if (strlen(optarg)>=MAX_REDIRECTOR_FILELEN) {
- debuga(_("Redirector log file name too long passed on command line with opton -L: %s\n"),optarg);
+ debuga(__FILE__,__LINE__,_("Redirector log file name too long passed on command line with opton -L: %s\n"),optarg);
exit(EXIT_FAILURE);
}
strcpy(RedirectorLogs[NRedirectorLogs],optarg);
if(strstr(optarg,"-") == 0) {
if(sscanf(optarg,"%d:%d",&h1,&m1)!=2) {
- debuga(_("Time period passed on the command line with option -t must be HH:MM\n"));
+ debuga(__FILE__,__LINE__,_("Time period passed on the command line with option -t must be HH:MM\n"));
exit(EXIT_FAILURE);
}
ReadFilter.StartTime=h1*100+m1;
snprintf(hm_str,sizeof(hm_str),"%02d:%02d",h1,m1);
} else {
if(sscanf(optarg,"%d:%d-%d:%d",&h1,&m1,&h2,&m2)!=4) {
- debuga(_("Time range passed on the command line with option -t must be HH:MM-HH:MM\n"));
+ debuga(__FILE__,__LINE__,_("Time range passed on the command line with option -t must be HH:MM-HH:MM\n"));
exit(EXIT_FAILURE);
}
ReadFilter.StartTime=h1*100+m1;
debugz++;
break;
case ':':
- debuga(_("Option -%c requires an argument\n"),optopt);
+ debuga(__FILE__,__LINE__,_("Option -%c requires an argument\n"),optopt);
exit(EXIT_FAILURE);
case '?':
usage(argv[0]);
AccessLog=FileList_Create();
for (iarq=optind ; iarq<argc ; iarq++) {
if (!FileList_AddFile(AccessLog,argv[iarq])) {
- debuga(_("Not enough memory to store the input log file names\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the input log file names\n"));
exit(EXIT_FAILURE);
}
AccessLogFromCmdLine++;
}
}
- if(debug) debuga(_("Init\n"));
+ if(debug) debuga(__FILE__,__LINE__,_("Init\n"));
if(ConfigFile[0] == '\0') snprintf(ConfigFile,sizeof(ConfigFile),"%s/sarg.conf",SYSCONFDIR);
if(access(ConfigFile, R_OK) != 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
exit(EXIT_FAILURE);
}
if(AccessLog==NULL) {
AccessLog=FileList_Create();
if (!FileList_AddFile(AccessLog,"/var/log/squid/access.log")) {
- debuga(_("Not enough memory to store the input log file names\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the input log file names\n"));
exit(EXIT_FAILURE);
}
}
strcat(tmp,"/sarg");
if (tmp[0]!='\0' && strncmp(outdir,tmp,strlen(tmp))==0) {
- debuga(_("The output directory \"%s\" must be outside of the temporary directory \"%s\"\n"),outdir,tmp);
+ debuga(__FILE__,__LINE__,_("The output directory \"%s\" must be outside of the temporary directory \"%s\"\n"),outdir,tmp);
exit(EXIT_FAILURE);
}
}
if(access(tmp, R_OK) == 0) {
- if (debug) debuga(_("Deleting temporary directory \"%s\"\n"),tmp);
+ if (debug) debuga(__FILE__,__LINE__,_("Deleting temporary directory \"%s\"\n"),tmp);
emptytmpdir(tmp);
}
my_mkdir(tmp);
if(debug) {
const char *file;
- debuga(_("Parameters:\n"));
- debuga(_(" Hostname or IP address (-a) = %s\n"),addr);
- debuga(_(" Useragent log (-b) = %s\n"),uagent);
- debuga(_(" Exclude file (-c) = %s\n"),hexclude);
- debuga(_(" Date from-until (-d) = %s\n"),ReadFilter.DateRange);
- debuga(_(" Email address to send reports (-e) = %s\n"),email);
- debuga(_(" Config file (-f) = %s\n"),ConfigFile);
+ debuga(__FILE__,__LINE__,_("Parameters:\n"));
+ debuga(__FILE__,__LINE__,_(" Hostname or IP address (-a) = %s\n"),addr);
+ debuga(__FILE__,__LINE__,_(" Useragent log (-b) = %s\n"),uagent);
+ debuga(__FILE__,__LINE__,_(" Exclude file (-c) = %s\n"),hexclude);
+ debuga(__FILE__,__LINE__,_(" Date from-until (-d) = %s\n"),ReadFilter.DateRange);
+ debuga(__FILE__,__LINE__,_(" Email address to send reports (-e) = %s\n"),email);
+ debuga(__FILE__,__LINE__,_(" Config file (-f) = %s\n"),ConfigFile);
if (df=='e')
- debuga(_(" Date format (-g) = Europe (dd/mm/yyyy)\n"));
+ debuga(__FILE__,__LINE__,_(" Date format (-g) = Europe (dd/mm/yyyy)\n"));
else if (df=='u')
- debuga(_(" Date format (-g) = USA (mm/dd/yyyy)\n"));
+ debuga(__FILE__,__LINE__,_(" Date format (-g) = USA (mm/dd/yyyy)\n"));
else if (df=='w')
- debuga(_(" Date format (-g) = Sites & Users (yyyy/ww)\n"));
- debuga(_(" IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
- debuga(_(" Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
+ debuga(__FILE__,__LINE__,_(" Date format (-g) = Sites & Users (yyyy/ww)\n"));
+ debuga(__FILE__,__LINE__,_(" IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
+ debuga(__FILE__,__LINE__,_(" Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
FIter=FileListIter_Open(AccessLog);
while ((file=FileListIter_NextWithMask(FIter))!=NULL)
- debuga(_(" Input log (-l) = %s\n"),file);
+ debuga(__FILE__,__LINE__,_(" Input log (-l) = %s\n"),file);
FileListIter_Close(FIter);
for (iarq=0 ; iarq<NRedirectorLogs ; iarq++)
- debuga(_(" Redirector log (-L) = %s\n"),RedirectorLogs[iarq]);
- debuga(_(" Resolve IP Address (-n) = %s\n"),(Ip2Name) ? _("Yes") : _("No"));
- debuga(_(" Output dir (-o) = %s\n"),outdir);
- debuga(_("Use Ip Address instead of userid (-p) = %s\n"),(UserIp) ? _("Yes") : _("No"));
- debuga(_(" Accessed site (-s) = %s\n"),site);
- debuga(_(" Time (-t) = %s\n"),hm_str);
- debuga(_(" User (-u) = %s\n"),us);
- debuga(_(" Temporary dir (-w) = %s\n"),tmp);
- debuga(_(" Debug messages (-x) = %s\n"),(debug) ? _("Yes") : _("No"));
- debuga(_(" Process messages (-z) = %d\n"),debugz);
- debuga(_(" Previous reports to keep (--lastlog) = %d\n"),LastLog);
- debuga("\n");
+ debuga(__FILE__,__LINE__,_(" Redirector log (-L) = %s\n"),RedirectorLogs[iarq]);
+ debuga(__FILE__,__LINE__,_(" Resolve IP Address (-n) = %s\n"),(Ip2Name) ? _("Yes") : _("No"));
+ debuga(__FILE__,__LINE__,_(" Output dir (-o) = %s\n"),outdir);
+ debuga(__FILE__,__LINE__,_("Use Ip Address instead of userid (-p) = %s\n"),(UserIp) ? _("Yes") : _("No"));
+ debuga(__FILE__,__LINE__,_(" Accessed site (-s) = %s\n"),site);
+ debuga(__FILE__,__LINE__,_(" Time (-t) = %s\n"),hm_str);
+ debuga(__FILE__,__LINE__,_(" User (-u) = %s\n"),us);
+ debuga(__FILE__,__LINE__,_(" Temporary dir (-w) = %s\n"),tmp);
+ debuga(__FILE__,__LINE__,_(" Debug messages (-x) = %s\n"),(debug) ? _("Yes") : _("No"));
+ debuga(__FILE__,__LINE__,_(" Process messages (-z) = %d\n"),debugz);
+ debuga(__FILE__,__LINE__,_(" Previous reports to keep (--lastlog) = %d\n"),LastLog);
+ debuga(__FILE__,__LINE__,"\n");
}
if(debug)
- debuga(_("sarg version: %s\n"),VERSION);
+ debuga(__FILE__,__LINE__,_("sarg version: %s\n"),VERSION);
#ifdef ENABLE_DOUBLE_CHECK_DATA
- debuga(_("Sarg compiled to report warnings if the output is inconsistent\n"));
+ debuga(__FILE__,__LINE__,_("Sarg compiled to report warnings if the output is inconsistent\n"));
#endif
#ifdef HAVE_RLIM_T
strftime(date0,sizeof(date0),"%x",&Start);
strftime(date1,sizeof(date1),"%x",&End);
// TRANSLATORS: The %s are the start and end dates in locale format.
- debuga(_("Period covered by log files: %s-%s\n"),date0,date1);
+ debuga(__FILE__,__LINE__,_("Period covered by log files: %s-%s\n"),date0,date1);
}
if (!LogStatus){
- debuga(_("No records found\n"));
- debuga(_("End\n"));
+ debuga(__FILE__,__LINE__,_("No records found\n"));
+ debuga(__FILE__,__LINE__,_("End\n"));
userinfo_free();
if(userfile) free(userfile);
close_usertab();
strftime(date0,sizeof(date0),"%x",&period.start);
strftime(date1,sizeof(date1),"%x",&period.end);
// TRANSLATORS: The %s are the start and end dates in locale format.
- debuga(_("Period extracted from log files: %s-%s\n"),date0,date1);
+ debuga(__FILE__,__LINE__,_("Period extracted from log files: %s-%s\n"),date0,date1);
}
if (ReadFilter.DateRange[0] != '\0') {
getperiod_fromrange(&period,dfrom,duntil);
}
if (getperiod_buildtext(&period)<0) {
- debuga(_("Failed to build the string representation of the date range\n"));
+ debuga(__FILE__,__LINE__,_("Failed to build the string representation of the date range\n"));
exit(EXIT_FAILURE);
}
if (show_statis) {
double elapsed=(double)end_time-(double)start_time;
- debuga(_("Total execution time: %.0lf seconds\n"),elapsed);
+ debuga(__FILE__,__LINE__,_("Total execution time: %.0lf seconds\n"),elapsed);
if (read_elapsed>0.) {
- debuga(_("Lines read: %lu lines in %.0lf seconds (%.0lf lines/s)\n"),lines_read,read_elapsed,(double)lines_read/read_elapsed);
+ debuga(__FILE__,__LINE__,_("Lines read: %lu lines in %.0lf seconds (%.0lf lines/s)\n"),lines_read,read_elapsed,(double)lines_read/read_elapsed);
}
if (process_elapsed>0.) {
- debuga(_("Processed records: %lu records in %.0lf seconds (%.0lf records/s)\n"),records_kept,process_elapsed,(double)records_kept/process_elapsed);
- debuga(_("Users: %lu users in %.0lf seconds (%.0lf users/s)\n"),nusers,process_elapsed,(double)nusers/process_elapsed);
+ debuga(__FILE__,__LINE__,_("Processed records: %lu records in %.0lf seconds (%.0lf records/s)\n"),records_kept,process_elapsed,(double)records_kept/process_elapsed);
+ debuga(__FILE__,__LINE__,_("Users: %lu users in %.0lf seconds (%.0lf users/s)\n"),nusers,process_elapsed,(double)nusers/process_elapsed);
}
}
if(debug)
- debuga(_("End\n"));
+ debuga(__FILE__,__LINE__,_("End\n"));
exit(EXIT_SUCCESS);
}
long int nreg=0;
if(debug)
- debuga(_("Loading password file \"%s\"\n"),pwdfile);
+ debuga(__FILE__,__LINE__,_("Loading password file \"%s\"\n"),pwdfile);
if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),pwdfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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 file \"%s\": %s\n"),pwdfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to move till the end of 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(__FILE__,__LINE__,_("Cannot get the size of file \"%s\"\n"),pwdfile);
exit(EXIT_FAILURE);
}
nreg = nreg+5000;
if (fseek(fp_usr, 0, SEEK_SET)==-1) {
- debuga(_("Failed to rewind file \"%s\": %s\n"),pwdfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to rewind file \"%s\": %s\n"),pwdfile,strerror(errno));
exit(EXIT_FAILURE);
}
if((userfile=(char *) malloc(nreg))==NULL){
- debuga(_("malloc error (%ld bytes required)\n"),nreg);
+ debuga(__FILE__,__LINE__,_("malloc error (%ld bytes required)\n"),nreg);
exit(EXIT_FAILURE);
}
while(fgets(buf,sizeof(buf),fp_usr)!=NULL) {
str=strchr(buf,':');
if (!str) {
- debuga(_("Invalid user in file \"%s\"\n"),pwdfile);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),pwdfile);
exit(EXIT_FAILURE);
}
str[1]='\0';
}
if (fclose(fp_usr)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),pwdfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),pwdfile,strerror(errno));
exit(EXIT_FAILURE);
}
if (line->length>=line->size) {
line->size+=LINE_BUFFER_SIZE_INCREMENT;
if (line->size>=MAX_LINE_BUFFER_SIZE) {
- debuga(_("A text line is more than %d bytes long denoting a corrupted file\n"),MAX_LINE_BUFFER_SIZE);
+ debuga(__FILE__,__LINE__,_("A text line is more than %d bytes long denoting a corrupted file\n"),MAX_LINE_BUFFER_SIZE);
exit(EXIT_FAILURE);
}
newbuf=realloc(line->buffer,line->size);
if (!newbuf) {
- debuga(_("Not enough memory to read one more line from the file\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to read one more line from the file\n"));
exit(EXIT_FAILURE);
}
line->buffer=newbuf;
line->size++;
newbuf=realloc(line->buffer,line->size);
if (!newbuf) {
- debuga(_("Not enough memory to read one more line from the file\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to read one more line from the file\n"));
exit(EXIT_FAILURE);
}
line->buffer=newbuf;
if (debugz>=LogLevel_Process)
{
/* TRANSLATORS: The argument is the log format name as translated by you. */
- debuga(_("Log format identified as \"%s\" for %s\n"),_(log_line->current_format->Name),log_line->file_name);
+ debuga(__FILE__,__LINE__,_("Log format identified as \"%s\" for %s\n"),_(log_line->current_format->Name),log_line->file_name);
}
break;
}
if (x>=(int)(sizeof(LogFormats)/sizeof(*LogFormats)))
{
if (++log_line->successive_errors>NumLogSuccessiveErrors) {
- debuga(ngettext("%d consecutive error found in the input log file %s\n",
+ debuga(__FILE__,__LINE__,ngettext("%d consecutive error found in the input log file %s\n",
"%d consecutive errors found in the input log file %s\n",log_line->successive_errors),log_line->successive_errors,log_line->file_name);
exit(EXIT_FAILURE);
}
if (NumLogTotalErrors>=0 && ++log_line->total_errors>NumLogTotalErrors) {
- debuga(ngettext("%d error found in the input log file (last in %s)\n",
+ debuga(__FILE__,__LINE__,ngettext("%d error found in the input log file (last in %s)\n",
"%d errors found in the input log file (last in %s)\n",log_line->total_errors),log_line->total_errors,log_line->file_name);
exit(EXIT_FAILURE);
}
- debuga(_("The following line read from %s could not be parsed and is ignored\n%s\n"),log_line->file_name,linebuf);
+ debuga(__FILE__,__LINE__,_("The following line read from %s could not be parsed and is ignored\n%s\n"),log_line->file_name,linebuf);
}
else
log_line->successive_errors=0;
}
if (log_line->current_format_idx<0 || log_line->current_format==NULL) {
- debuga(_("Sarg failed to determine the format of the input log file %s\n"),log_line->file_name);
+ debuga(__FILE__,__LINE__,_("Sarg failed to determine the format of the input log file %s\n"),log_line->file_name);
exit(EXIT_FAILURE);
}
if (log_entry_status==RLRC_InternalError) {
- debuga(_("Internal error encountered while processing %s\nSee previous message to know the reason for that error.\n"),log_line->file_name);
+ debuga(__FILE__,__LINE__,_("Internal error encountered while processing %s\nSee previous message to know the reason for that error.\n"),log_line->file_name);
exit(EXIT_FAILURE);
}
return(log_entry_status);
if (arq[0]=='-' && arq[1]=='\0') {
if(debug)
- debuga(_("Reading access log file: from stdin\n"));
+ debuga(__FILE__,__LINE__,_("Reading access log file: from stdin\n"));
fp_in=stdin;
from_stdin=true;
} else {
if (Filter->DateRange[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(__FILE__,__LINE__,_("Cannot get the modification time of input log file %s (%s). Processing 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) {
- debuga(_("Ignoring old log file %s\n"),arq);
+ debuga(__FILE__,__LINE__,_("Ignoring old log file %s\n"),arq);
return;
}
}
}
fp_in=decomp(arq,&from_pipe);
if(fp_in==NULL) {
- debuga(_("Cannot open input log file \"%s\": %s\n"),arq,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open input log file \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
- if(debug) debuga(_("Reading access log file: %s\n"),arq);
+ if(debug) debuga(__FILE__,__LINE__,_("Reading access log file: %s\n"),arq);
from_stdin=false;
}
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arq);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arq);
exit(EXIT_FAILURE);
}
getword_start(&gwarea,ExcludeString);
while(strchr(gwarea.current,':') != 0) {
if (getword_multisep(val1,sizeof(val1),&gwarea,':')<0) {
- debuga(_("Invalid record in exclusion string\n"));
+ debuga(__FILE__,__LINE__,_("Invalid record in exclusion string\n"));
exit(EXIT_FAILURE);
}
if((str=(char *) strstr(linebuf,val1)) != (char *) NULL ) {
my_mkdir(ParsedOutputLog);
}
if (snprintf(SargLogFile,sizeof(SargLogFile),"%s/sarg_temp.log",ParsedOutputLog)>=sizeof(SargLogFile)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sarg_temp.log\n",ParsedOutputLog);
exit(EXIT_FAILURE);
}
if((fp_log=MY_FOPEN(SargLogFile,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),SargLogFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),SargLogFile,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("*** SARG Log ***\n",fp_log);
}
if (log_entry.Ip==NULL) {
- debuga(_("Unknown input log file format: no IP addresses\n"));
+ debuga(__FILE__,__LINE__,_("Unknown input log file format: no IP addresses\n"));
break;
}
if (log_entry.User==NULL) {
- debuga(_("Unknown input log file format: no user\n"));
+ debuga(__FILE__,__LINE__,_("Unknown input log file format: no user\n"));
break;
}
if (log_entry.Url==NULL) {
- debuga(_("Unknown input log file format: no URL\n"));
+ debuga(__FILE__,__LINE__,_("Unknown input log file format: no URL\n"));
break;
}
if(strlen(log_entry.User) > MAX_USER_LEN) {
- if (debugz>=LogLevel_Process) debuga(_("User ID too long: %s\n"),log_entry.User);
+ if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("User ID too long: %s\n"),log_entry.User);
excluded_count[ER_UserNameTooLong]++;
totregsx++;
continue;
}
if(vercode(log_entry.HttpCode)) {
- if (debugz>=LogLevel_Process) debuga(_("Excluded code: %s\n"),log_entry.HttpCode);
+ if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("Excluded code: %s\n"),log_entry.HttpCode);
excluded_count[ER_HttpCode]++;
totregsx++;
continue;
}
if(Filter->HostFilter) {
if(!vhexclude(url)) {
- if (debugz>=LogLevel_Data) debuga(_("Excluded site: %s\n"),url);
+ if (debugz>=LogLevel_Data) debuga(__FILE__,__LINE__,_("Excluded site: %s\n"),url);
excluded_count[ER_Url]++;
totregsx++;
continue;
if(Filter->UserFilter) {
if(!vuexclude(log_entry.User)) {
- if (debugz>=LogLevel_Process) debuga(_("Excluded user: %s\n"),log_entry.User);
+ if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("Excluded user: %s\n"),log_entry.User);
excluded_count[ER_IgnoredUser]++;
totregsx++;
continue;
if (!ufile) {
ufile=malloc(sizeof(*ufile));
if (!ufile) {
- debuga(_("Not enough memory to store the user %s\n"),log_entry.User);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user %s\n"),log_entry.User);
exit(EXIT_FAILURE);
}
memset(ufile,0,sizeof(*ufile));
if (ufile1->file!=NULL) {
if (x>=maxopenfiles) {
if (fclose(ufile1->file)==EOF) {
- debuga(_("Write error in log file of user %s: %s\n"),ufile1->user->id,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in log file of user %s: %s\n"),ufile1->user->id,strerror(errno));
exit(EXIT_FAILURE);
}
ufile1->file=NULL;
}
}
if (snprintf (tmp3, sizeof(tmp3), "%s/%s.user_unsort", tmp, ufile->user->filename)>=sizeof(tmp3)) {
- debuga(_("Temporary user file name too long: %s/%s.user_unsort\n"), tmp, ufile->user->filename);
+ debuga(__FILE__,__LINE__,_("Temporary user file name too long: %s/%s.user_unsort\n"), tmp, ufile->user->filename);
exit(EXIT_FAILURE);
}
if ((ufile->file = MY_FOPEN (tmp3, "a")) == NULL) {
- debuga(_("(log) Cannot open temporary file %s: %s\n"), tmp3, strerror(errno));
+ debuga(__FILE__,__LINE__,_("(log) Cannot open temporary file %s: %s\n"), tmp3, strerror(errno));
exit (1);
}
}
if (fprintf(ufile->file, "%s\t%s\t%s\t%s\t%"PRIu64"\t%s\t%ld\t%s\n",dia,hora,
log_entry.Ip,url,(uint64_t)log_entry.DataSize,
log_entry.HttpCode,log_entry.ElapsedTime,smartfilter)<=0) {
- debuga(_("Write error in the log file of user %s\n"),log_entry.User);
+ debuga(__FILE__,__LINE__,_("Write error in the log file of user %s\n"),log_entry.User);
exit(EXIT_FAILURE);
}
records_kept++;
static void DisplayExcludeCount(const char *Explain,enum ExcludeReasonEnum Reason)
{
if (excluded_count[Reason]>0) {
- debuga(" %s: %lu\n",Explain,excluded_count[Reason]);
+ debuga(__FILE__,__LINE__," %s: %lu\n",Explain,excluded_count[Reason]);
}
}
char val4[4096];//val4 must not be bigger than SargLogFile without fixing the strcpy below
if (fclose(fp_log)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),SargLogFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),SargLogFile,strerror(errno));
exit(EXIT_FAILURE);
}
strftime(val2,sizeof(val2),"%d%m%Y_%H%M",&period.start);
strftime(val1,sizeof(val1),"%d%m%Y_%H%M",&period.end);
if (snprintf(val4,sizeof(val4),"%s/sarg-%s-%s.log",ParsedOutputLog,val2,val1)>=sizeof(val4)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sarg-%s-%s.log\n",ParsedOutputLog,val2,val1);
exit(EXIT_FAILURE);
}
if (rename(SargLogFile,val4)) {
- debuga(_("failed to rename %s to %s - %s\n"),SargLogFile,val4,strerror(errno));
+ debuga(__FILE__,__LINE__,_("failed to rename %s to %s - %s\n"),SargLogFile,val4,strerror(errno));
} else {
strcpy(SargLogFile,val4);
necessary around the command name, put them in the configuration file.
*/
if (snprintf(val1,sizeof(val1),"%s \"%s\"",ParsedOutputLogCompress,SargLogFile)>=sizeof(val1)) {
- debuga(_("Command too long: %s \"%s\"\n"),ParsedOutputLogCompress,SargLogFile);
+ debuga(__FILE__,__LINE__,_("Command too long: %s \"%s\"\n"),ParsedOutputLogCompress,SargLogFile);
exit(EXIT_FAILURE);
}
cstatus=system(val1);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("command: %s\n"),val1);
+ debuga(__FILE__,__LINE__,_("command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("command: %s\n"),val1);
exit(EXIT_FAILURE);
}
}
}
if(debug)
- debuga(_("Sarg parsed log saved as %s\n"),SargLogFile);
+ debuga(__FILE__,__LINE__,_("Sarg parsed log saved as %s\n"),SargLogFile);
}
denied_close();
for (ufile=first_user_file ; ufile ; ufile=ufile1) {
ufile1=ufile->next;
if (ufile->file!=NULL && fclose(ufile->file)==EOF) {
- debuga(_("Write error in log file of user %s: %s\n"),ufile->user->id,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in log file of user %s: %s\n"),ufile->user->id,strerror(errno));
exit(EXIT_FAILURE);
}
free(ufile);
if (debug) {
unsigned long int totalcount=0;
- debuga(_(" Records read: %ld, written: %ld, excluded: %ld\n"),totregsl,totregsg,totregsx);
+ debuga(__FILE__,__LINE__,_(" Records read: %ld, written: %ld, excluded: %ld\n"),totregsl,totregsg,totregsx);
for (x=sizeof(excluded_count)/sizeof(*excluded_count)-1 ; x>=0 && excluded_count[x]>0 ; x--);
if (x>=0) {
- debuga(_("Reasons for excluded entries:\n"));
+ debuga(__FILE__,__LINE__,_("Reasons for excluded entries:\n"));
DisplayExcludeCount(_("User name too long"),ER_UserNameTooLong);
DisplayExcludeCount(_("Squid logged an incomplete query received from the client"),ER_IncompleteQuery);
DisplayExcludeCount(_("Log file turned over"),ER_LogfileTurnedOver);
/* TRANSLATORS: It displays the number of lines found in the input log files
* for each supported log format. The log format name is the %s and is a string
* you translate somewhere else. */
- debuga(_("%s: %lu entries\n"),_(LogFormats[x]->Name),format_count[x]);
+ debuga(__FILE__,__LINE__,_("%s: %lu entries\n"),_(LogFormats[x]->Name),format_count[x]);
totalcount+=format_count[x];
}
}
if (totalcount==0 && totregsg)
- debuga(_("Log with invalid format\n"));
+ debuga(__FILE__,__LINE__,_("Log with invalid format\n"));
}
return((totregsg!=0) ? 1 : 0);
// check the entry time
if (mktime(&Entry->EntryTime)==-1) {
- debuga(_("Invalid date or time found in the common log file\n"));
+ debuga(__FILE__,__LINE__,_("Invalid date or time found in the common log file\n"));
return(RLRC_InternalError);
}
col=0;
while (*columns) {
if (col>=MAX_EXT_COLUMNS) {
- debuga(_("Too many columns found in an extended log format. The maximum allowed is %d but it can be changed if a bigger value is legitimate\n"),MAX_EXT_COLUMNS);
+ debuga(__FILE__,__LINE__,_("Too many columns found in an extended log format. The maximum allowed is %d but it can be changed if a bigger value is legitimate\n"),MAX_EXT_COLUMNS);
exit(EXIT_FAILURE);
}
prefix=-1;
columns+=len;
while (*columns && (unsigned char)*columns<=' ') {
if (*columns!=col_sep) {
- debuga(_("Multiple column separators found between two columns in the \"fields\" directive of an extended log format\n"));
+ debuga(__FILE__,__LINE__,_("Multiple column separators found between two columns in the \"fields\" directive of an extended log format\n"));
exit(EXIT_FAILURE);
}
columns++;
col=0;
while (*Line) {
if (col>=ExtColNumber) {
- debuga(_("Too many columns in an extended log file format: %d columns found when %d have been announced\n"),col,ExtColNumber);
+ debuga(__FILE__,__LINE__,_("Too many columns in an extended log file format: %d columns found when %d have been announced\n"),col,ExtColNumber);
return(RLRC_Unknown);
}
col_id=ExtLog_WhichColumn(col);
col++;
}
if (col!=ExtColNumber) {
- debuga(_("Only %d columns in an extended log file format when %d have been announced\n"),col,ExtColNumber);
+ debuga(__FILE__,__LINE__,_("Only %d columns in an extended log file format when %d have been announced\n"),col,ExtColNumber);
return(RLRC_Unknown);
}
// check the entry time
if (mktime(&Entry->EntryTime)==-1) {
- debuga(_("Invalid date or time found in the extended log file\n"));
+ debuga(__FILE__,__LINE__,_("Invalid date or time found in the extended log file\n"));
return(RLRC_InternalError);
}
if (strncmp(Line,"*** SARG Log ***",16)==0) {
if (InvalidFileName) {
- debuga(_("The name of the file is invalid for a sarg log\n"));
+ debuga(__FILE__,__LINE__,_("The name of the file is invalid for a sarg log\n"));
exit(EXIT_FAILURE);
}
getperiod_merge(&period,&SargPeriod);
// check the entry time
if (mktime(&Entry->EntryTime)==-1) {
- debuga(_("Invalid date or time found in the common log file\n"));
+ debuga(__FILE__,__LINE__,_("Invalid date or time found in the common log file\n"));
return(RLRC_InternalError);
}
// now, the format is known with a good confidence. If the time doesn't decode, it is an error.
tt=localtime(&log_time);
if (tt==NULL) {
- debuga(_("Cannot convert the timestamp from the squid log file\n"));
+ debuga(__FILE__,__LINE__,_("Cannot convert the timestamp from the squid log file\n"));
return(RLRC_InternalError);
}
memcpy(&Entry->EntryTime,tt,sizeof(struct tm));
while ((file=FileListIter_Next(FIter))!=NULL)
{
if (stat(file,&st)==-1) {
- debuga(_("Cannot stat \"%s\": %s\n"),file,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"),file,strerror(errno));
}
if (!found)
{
StoredLogEntries=calloc(realtime_access_log_lines+1,sizeof(struct RealtimeReadLogStruct));
if (!StoredLogEntries)
{
- debuga(_("Not enough memory to store %d records"),realtime_access_log_lines);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store %d records"),realtime_access_log_lines);
exit(EXIT_FAILURE);
}
/*
if (!GetLatestModified(file_name,sizeof(file_name)))
{
- debuga(_("No log file to read the last %d lines from\n"),realtime_access_log_lines);
+ debuga(__FILE__,__LINE__,_("No log file to read the last %d lines from\n"),realtime_access_log_lines);
exit(EXIT_FAILURE);
}
fp = fopen(file_name, "r");
if (!fp) {
- debuga(_("Cannot open file \"%s\": %s\n"),file_name,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),file_name,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),file_name);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),file_name);
exit(EXIT_FAILURE);
}
if (NextIndex>realtime_access_log_lines) NextIndex=0;
}
if (fclose(fp)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),file_name,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),file_name,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
getword_start(&gwarea1,RedirectorLogFormat);
leks[0]='\0';
if (getword(leks,sizeof(leks),&gwarea1,'#')<0) {
- debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters before first tag)\n"));
+ debuga(__FILE__,__LINE__,_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters before first tag)\n"));
exit(EXIT_FAILURE);
}
year=0;
full_url[0]='\0';
while(strcmp(leks,"end") != 0) {
if (getword(leks,sizeof(leks),&gwarea1,'#')<0) {
- debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (missing # at end of tag)\n"));
+ debuga(__FILE__,__LINE__,_("Invalid \"redirector_log_format\" option in your sarg.conf (missing # at end of tag)\n"));
exit(EXIT_FAILURE);
}
if (getword(sep,sizeof(sep),&gwarea1,'#')<0) {
- debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters in column separator)\n"));
+ debuga(__FILE__,__LINE__,_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters in column separator)\n"));
exit(EXIT_FAILURE);
}
if(strcmp(leks,"end") != 0) {
if (getword_limit(res,sizeof(res),&gwarea,sep[0])<0) {
- debuga(_("Parsing of tag \"%s\" in redirector log \"%s\" returned no result\n"),leks,wentp);
+ debuga(__FILE__,__LINE__,_("Parsing of tag \"%s\" in redirector log \"%s\" returned no result\n"),leks,wentp);
RedirectorErrors++;
return;
}
day=atoi(res);
} else if(strcmp(leks,"hour") == 0) {
if (strlen(res)>=sizeof(hour)) {
- debuga(_("Hour string too long in redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Hour string too long in redirector log file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
strcpy(hour,res);
} else if(strcmp(leks,"source") == 0) {
if (strlen(res)>=sizeof(source)) {
- debuga(_("Banning source name too long in redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Banning source name too long in redirector log file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
strcpy(source,res);
} else if(strcmp(leks,"list") == 0) {
if (strlen(res)>=sizeof(list)) {
- debuga(_("Banning list name too long in redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Banning list name too long in redirector log file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
strcpy(list,res);
} else if(strcmp(leks,"ip") == 0) {
if (strlen(res)>=sizeof(ip)) {
- debuga(_("IP address too long in redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("IP address too long in redirector log file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
strcpy(ip,res);
} else if(strcmp(leks,"user") == 0) {
if (strlen(res)>=sizeof(user)) {
- debuga(_("User ID too long in redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("User ID too long in redirector log file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
} else {
if (getword_atoll(&lyear,&gwarea,'-')<0 || getword_atoll(&lmon,&gwarea,'-')<0 ||
getword_atoll(&lday,&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
mon=(int)lmon;
day=(int)lday;
if (getword(hour,sizeof(hour),&gwarea,' ')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
if (getword_skip(MAXLEN,&gwarea,'(')<0 || getword(source,sizeof(source),&gwarea,'/')<0) {
- debuga(_("Invalid redirected source in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid redirected source in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
if (getword(list,sizeof(list),&gwarea,'/')<0) {
- debuga(_("Invalid redirected list in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid redirected list in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword_limit(full_url,sizeof(full_url),&gwarea,' ')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
if (getword(ip,sizeof(ip),&gwarea,'/')<0) {
- debuga(_("Invalid source IP in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid source IP in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,' ')<0) {
- debuga(_("Invalid user in file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),wentp);
RedirectorErrors++;
return;
}
longline line;
if(debug) {
- debuga(_("Reading redirector log file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Reading redirector log file \"%s\"\n"),wentp);
}
/* With squidGuard, you can log groups in only one log file.
nfiles_done++;
files_done = realloc(files_done, nfiles_done*sizeof(char *));
if (!files_done) {
- debuga(_("Not enough memory to store the name of the new redirector log to be read - %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the name of the new redirector log to be read - %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
files_done[nfiles_done-1] = strdup(wentp);
if (!files_done[nfiles_done-1]) {
- debuga(_("Not enough memory to store the name of the new redirector log to be read - %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the name of the new redirector log to be read - %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
if ((fp_in=fopen(wentp,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wentp,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wentp,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),wentp);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wentp);
exit(EXIT_FAILURE);
}
parse_log(fp_ou,buf);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wentp,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wentp,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
str2 = user;
if(SquidGuardConf[0] == '\0' && NRedirectorLogs == 0) {
- if (debugz>=LogLevel_Process) debugaz(_("No redirector logs provided to produce that kind of report\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("No redirector logs provided to produce that kind of report\n"));
return;
}
snprintf(guard_in,sizeof(guard_in),"%s/redirector.int_unsort",tmp);
if((fp_ou=fopen(guard_in,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
read_log(RedirectorLogs[i],fp_ou,dfrom,duntil);
} else {
if(access(SquidGuardConf, R_OK) != 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),SquidGuardConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),SquidGuardConf,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_guard=fopen(SquidGuardConf,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),SquidGuardConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),SquidGuardConf,strerror(errno));
exit(EXIT_FAILURE);
}
}
}
if (fclose(fp_guard)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),SquidGuardConf,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),SquidGuardConf,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (fp_ou && fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
if (redirector_count) {
snprintf(redirector_sorted,sizeof(redirector_sorted),"%s/redirector.int_log",tmp);
if(debug) {
- debuga(_("Sorting file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),redirector_sorted);
}
if (snprintf(tmp6,sizeof(tmp6),"sort -t \"\t\" -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, redirector_sorted)>=sizeof(tmp6)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),guard_in,redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),guard_in,redirector_sorted);
exit(EXIT_FAILURE);
}
cstatus=system(tmp6);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),tmp6);
+ debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),tmp6);
exit(EXIT_FAILURE);
}
}
if (!KeepTempLog && unlink(guard_in)) {
- debuga(_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
exit(EXIT_FAILURE);
}
return;
if(!redirector_count) {
if (debugz>=LogLevel_Process) {
if (redirector_sorted[0])
- debugaz(_("Redirector report not generated because it is empty\n"));
+ debugaz(__FILE__,__LINE__,_("Redirector report not generated because it is empty\n"));
}
return;
}
snprintf(report,sizeof(report),"%s/redirector.html",outdirname);
if((fp_in=fopen(redirector_sorted,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),redirector_sorted,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),redirector_sorted,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("Invalid user in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
if (getword_atoll(&data2,&gwarea,'\t')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("Invalid IP address in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid IP address in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
if (getword(rule,sizeof(rule),&gwarea,'\n')<0) {
- debuga(_("Invalid rule in file \"%s\"\n"),redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Invalid rule in file \"%s\"\n"),redirector_sorted);
exit(EXIT_FAILURE);
}
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,redirector_sorted);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,redirector_sorted);
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),redirector_sorted,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),redirector_sorted,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fputs("</div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(redirector_sorted)) {
- debuga(_("Cannot delete \"%s\": %s\n"),redirector_sorted,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),redirector_sorted,strerror(errno));
exit(EXIT_FAILURE);
}
if(access(wdirname, R_OK) != 0) return;
if (snprintf(arqout,sizeof(arqout),"%s/%s/d%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqout)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s/d%s.html\n",outdirname,uinfo->filename,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(wdirname,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(buf);
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,'\t')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
if (sscanf(data,"%d/%d/%d",&day,&month,&year)!=3) continue;
for (dayidx=0 ; dayidx<ndaylist && daynum!=daylist[dayidx] ; dayidx++);
if (dayidx>=ndaylist) {
if (dayidx>=sizeof(daylist)/sizeof(*daylist)) {
- debuga(_("Too many different dates in file \"%s\"\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Too many different dates in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
daylist[ndaylist++]=daynum;
}
if (getword_atoll(&hour,&gwarea,'\t')<0) {
- debuga(_("Invalid time in file \"%s\"\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
ihour=(int)hour;
if ((datetimeby & DATETIME_BYTE)!=0) {
colsep=((datetimeby & DATETIME_ELAP)!=0) ? '\t' : '\0';
if (getword_atoll(&bytes,&gwarea,colsep)<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);
}
tbytes[i]+=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);
}
telap[i]+=elap;
}
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(arqout,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</table>\n",fp_ou);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (tt!=uinfo->nbytes) {
- debuga(_("Total downloaded bytes is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
+ debuga(__FILE__,__LINE__,_("Total downloaded bytes is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
(int64_t)tt,(int64_t)uinfo->nbytes,uinfo->label);
exit(EXIT_FAILURE);
}
fputs("</table>\n",fp_ou);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (tt!=uinfo->elap) {
- debuga(_("Total elapsed time is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
+ debuga(__FILE__,__LINE__,_("Total elapsed time is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
(int64_t)tt,(int64_t)uinfo->elap,uinfo->label);
exit(EXIT_FAILURE);
}
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
return;
memset(&globstat,0,sizeof(globstat));
if (vrfydir(&period, addr, site, us, email)<0) {
- debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
+ debuga(__FILE__,__LINE__,_("Cannot create the output directory name containing the period as part of the name\n"));
exit(EXIT_FAILURE);
}
if(debugz>=LogLevel_Process){
- debugaz(_("outdirname=%s\n"),outdirname);
+ debugaz(__FILE__,__LINE__,_("outdirname=%s\n"),outdirname);
}
if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname);
if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
uscan=userinfo_startscan();
if (uscan == NULL) {
- debuga(_("Cannot enumerate the user list\n"));
+ debuga(__FILE__,__LINE__,_("Cannot enumerate the user list\n"));
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(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.user_log\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_in=MY_FOPEN(tmp3,"r"))==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);
}
user=uinfo->filename;
oucache=0;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
getword(accip,sizeof(accip),&gwarea,'\t')<0 ||
getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
getword(acccode,sizeof(acccode),&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
if (getword_atoll(&accelap,&gwarea,'\t')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
- debuga(_("Invalid smart info in file \"%s\"\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid smart info in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
my_mkdir(arqtt);
snprintf(arqtt,sizeof(arqtt),"%s/%s/tt.html",outdirname,uinfo->filename);
if ((fp_tt = fopen(arqtt, "w")) == 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),arqtt,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqtt,strerror(errno));
exit(EXIT_FAILURE);
}
ttopen=1;
ourltt_size=url_len+1;
oldurltt=realloc(oldurltt,ourltt_size);
if (!oldurltt) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
strcpy(oldacchora,acchora);
}
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);
}
longline_destroy(&line);
}
if (fp_tmp) {
if (fclose(fp_tmp)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),uinfo->filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),uinfo->filename,strerror(errno));
exit(EXIT_FAILURE);
}
fp_tmp=NULL;
}
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);
}
}
totalger(fp_gen,wdirname);
if (fclose(fp_gen)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
if(DansGuardianConf[0] != '\0')
dansguardian_log();
else if (debugz>=LogLevel_Process)
- debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
+ debugaz(__FILE__,__LINE__,_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
redirector_log();
}
if((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
download_report();
else if (debugz>=LogLevel_Process)
- debugaz(_("Downloaded files report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("Downloaded files report not requested in report_type\n"));
if((ReportType & REPORT_TYPE_TOPSITES) != 0)
topsites();
else if (debugz>=LogLevel_Process)
- debugaz(_("Top sites report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("Top sites report not requested in report_type\n"));
if((ReportType & REPORT_TYPE_SITES_USERS) != 0)
siteuser();
else if (debugz>=LogLevel_Process)
- debugaz(_("Sites & users report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("Sites & users report not requested in report_type\n"));
if ((ReportType & REPORT_TYPE_DENIED) != 0)
gen_denied_report();
else if (debugz>=LogLevel_Process)
- debugaz(_("Denied accesses report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("Denied accesses report not requested in report_type\n"));
if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0)
authfail_report();
else if (debugz>=LogLevel_Process)
- debugaz(_("Authentication failures report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("Authentication failures report not requested in report_type\n"));
if(smartfilter) smartfilter_report();
if((ReportType & REPORT_TYPE_USERS_SITES) != 0)
htmlrel();
else if (debugz>=LogLevel_Process)
- debugaz(_("User's detailed report not requested in report_type\n"));
+ debugaz(__FILE__,__LINE__,_("User's detailed report not requested in report_type\n"));
}
make_index();
- if(SuccessfulMsg) debuga(_("Successful report generated on %s\n"),outdirname);
+ if(SuccessfulMsg) debuga(__FILE__,__LINE__,_("Successful report generated on %s\n"),outdirname);
} else {
geramail(outdirname, debug, outdir, email, tmp);
if((strcmp(email,"stdout") != 0) && SuccessfulMsg)
- debuga(_("Successful report generated and sent to %s\n"),email);
+ debuga(__FILE__,__LINE__,_("Successful report generated and sent to %s\n"),email);
}
if(indexonly) index_only(outdirname, debug);
if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return(NULL);
if((ReportType & REPORT_TYPE_TOPUSERS) == 0) return(NULL);
- if(debug) debuga(_("Making file %s/%s\n"),tmp,user);
+ if(debug) debuga(__FILE__,__LINE__,_("Making file %s/%s\n"),tmp,user);
if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,user)>=sizeof(wdirname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.utmp\n",tmp,user);
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(wdirname,"w"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</table>\n</div>\n",fp_tt);
fputs("</body>\n</html>\n",fp_tt);
if (fclose(fp_tt)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),arqtt,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqtt,strerror(errno));
exit(EXIT_FAILURE);
}
fp_tt=NULL;
if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(wdirname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.ip\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"%s\t%s\t%s\t%s\t%"PRIu64"\t%"PRIu64"\n",ip,url,data,hora,(uint64_t)tam,(uint64_t)elap);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
to print a long long int unless it is exactly 64-bits long.
*/
if (fprintf(fp_gen,"%s\t%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",uinfo->id,(uint64_t)nacc,(uint64_t)nbytes,url,ip,hora,dia,(uint64_t)nelap,(uint64_t)incache,(uint64_t)oucache)<0) {
- debuga(_("Write error in file \"%s\": %s\n"),filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in file \"%s\": %s\n"),filename,strerror(errno));
exit(EXIT_FAILURE);
}
to print a long long int unless it is exactly 64-bits long.
*/
if (fprintf(fp_gen,"TOTAL\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",(uint64_t)globstat.nacc,(uint64_t)globstat.nbytes,(uint64_t)globstat.elap,(uint64_t)globstat.incache,(uint64_t)globstat.oucache)<0) {
- debuga(_("Failed to write the total line in %s\n"),filename);
+ debuga(__FILE__,__LINE__,_("Failed to write the total line in %s\n"),filename);
exit(EXIT_FAILURE);
}
}
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid total number of accesses in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid total number of accesses in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid total size in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid total size in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid total elapsed time in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid total elapsed time in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid total cache hit in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid total cache hit in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\0') {
- debuga(_("Invalid total cache miss in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid total cache miss in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
item->oucache=number*sign;
item->user=buffer;
for (i=0 ; i<MAX_USER_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') {
- debuga(_("User name too long or invalid in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("User name too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
*buffer++='\0';
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid number of accesses in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid number of bytes in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
item->url=buffer;
while ((unsigned char)*buffer>=' ') buffer++;
if (*buffer!='\t') {
- debuga(_("URL too long or invalid in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("URL too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
*buffer++='\0';
item->ip=buffer;
for (i=0 ; i<MAX_IP_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') {
- debuga(_("IP address too long or invalid in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("IP address too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
*buffer++='\0';
item->time=buffer;
for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') {
- debuga(_("Time too long or invalid in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Time too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
*buffer++='\0';
item->date=buffer;
for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') {
- debuga(_("Date too long or invalid in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Date too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
*buffer++='\0';
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') {
- debuga(_("Invalid cache hit size in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid cache hit size in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
buffer++;
while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\0') {
- debuga(_("Invalid cache miss size in file \"%s\"\n"),filename);
+ debuga(__FILE__,__LINE__,_("Invalid cache miss size in file \"%s\"\n"),filename);
exit(EXIT_FAILURE);
}
item->oucache=number*sign;
char wdirname[MAXLEN];
if (snprintf(wdirname,sizeof(wdirname),"%s/smartfilter.int_unsort",dirname)>=sizeof(wdirname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/smartfilter.int_unsort\n",dirname);
exit(EXIT_FAILURE);
}
if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</body>\n</html>\n",fp_tt);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
struct userinfostruct *uinfo;
if(Privacy) {
- if (debugz>=LogLevel_Process) debugaz(_("Sites & users report not generated because privacy option is on\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Sites & users report not generated because privacy option is on\n"));
return;
}
if (debugz>=LogLevel_Process)
- debuga(_("Creating report to list who visisted what site...\n"));
+ debuga(__FILE__,__LINE__,_("Creating report to list who visisted what site...\n"));
nsitesusers = 0;
sprintf(general,"%s/sarg-general",outdirname);
sprintf(sites,"%s/sarg-sites",outdirname);
sprintf(report,"%s/siteuser.html",outdirname);
if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
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(general2,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),general2,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
topuser_link=((ReportType & REPORT_TYPE_USERS_SITES) != 0 && !indexonly);
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),general2);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),general2);
exit(EXIT_FAILURE);
}
if(item.total) continue;
uinfo=userinfo_find_from_id(item.user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),item.user,general2);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),item.user,general2);
exit(EXIT_FAILURE);
}
ourl_size=url_len+1;
ourl=realloc(ourl,ourl_size);
if (!ourl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),general2,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
if (ourl) free(ourl);
if (!KeepTempLog && unlink(general2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
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"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
ouser[0]='\0';
if (snprintf(smart_in,sizeof(smart_in),"%s/smartfilter.int_unsort",tmp)>=sizeof(smart_in)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/smartfilter.int_unsort\n",tmp);
exit(EXIT_FAILURE);
}
if (snprintf(sites,sizeof(sites),"%s/sarg-sites",outdirname)>=sizeof(sites)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sarg-sites\n",outdirname);
exit(EXIT_FAILURE);
}
if (snprintf(smart_ou,sizeof(smart_ou),"%s/smartfilter.int_log",tmp)>=sizeof(smart_ou)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/smartfilter.int_log\n",tmp);
exit(EXIT_FAILURE);
}
if (snprintf(report,sizeof(report),"%s/smartfilter.html",outdirname)>=sizeof(report)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/smartfilter.html\n",outdirname);
exit(EXIT_FAILURE);
}
if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -k 1,1 -k 2,2 -k 3,3 -o \"%s\" \"%s\"",smart_ou,smart_in)>=sizeof(csort)) {
- debuga(_("Cannot build the sort command to sort file \"%s\"\n"),smart_in);
+ debuga(__FILE__,__LINE__,_("Cannot build the sort command to sort file \"%s\"\n"),smart_in);
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(smart_ou,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),smart_ou,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),smart_ou,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(smart_in)) {
- debuga(_("Cannot delete \"%s\": %s\n"),smart_in,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),smart_in,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if (getword(user,sizeof(user),&gwarea,'\t')<0 || getword(data,sizeof(data),&gwarea,'\t')<0 ||
getword(hora,sizeof(hora),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0 ||
getword(url,sizeof(url),&gwarea,'\t')<0 || getword(smartcat,sizeof(smartcat),&gwarea,'\n')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),smart_ou);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),smart_ou);
exit(EXIT_FAILURE);
}
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,smart_ou);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,smart_ou);
exit(EXIT_FAILURE);
}
if(strcmp(ouser,user) != 0) {
}
fputs("</body>\n</html>\n",fp_user);
if (fclose(fp_user)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),smartuser,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),smartuser,strerror(errno));
exit(EXIT_FAILURE);
}
fp_user=NULL;
}
if ((fp_user = fopen(smartuser, "a")) == 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),smartuser,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),smartuser,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</body>\n</html>\n",fp_user);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
if(fp_user) {
}
fputs("</body>\n</html>\n",fp_user);
if (fclose(fp_user)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),smartuser,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),smartuser,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (!KeepTempLog && unlink(smart_ou)) {
- debuga(_("Cannot delete \"%s\": %s\n"),smart_ou,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),smart_ou,strerror(errno));
exit(EXIT_FAILURE);
}
order="-r";
if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(arqin)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.utmp\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if (snprintf(arqou,sizeof(arqou),"%s/htmlrel.txt",tmp)>=sizeof(arqou)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/htmlrel.txt\n",tmp);
exit(EXIT_FAILURE);
}
if(debug) {
- debuga(_("Sorting file \"%s\"\n"),arqin);
+ debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),arqin);
}
if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
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 (!KeepTempLog && unlink(arqin)) {
- debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug) {
snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,uinfo->filename);
- debuga(_("Sorting file \"%s\"\n"),csort);
+ debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),csort);
}
user=uinfo->filename;
tmp, tmp, user, tmp, user);
if (clen>=sizeof(csort)) {
/* TRANSLATORS: The message is followed by the command that is too long. */
- debuga(_("User name too long to sort with command "));
+ debuga(__FILE__,__LINE__,_("User name too long to sort with command "));
debuga_more("sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"%s/%s.user_log\" \"%s/%s.user_unsort\"",
tmp, tmp, user, tmp, user);
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 (snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,user)>=sizeof(csort)) {
- debuga(_("User name too long to manufacture file name "));
+ debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
debuga_more("%s/%s.user_unsort\n",tmp,user);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(csort)) {
- debuga(_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
exit(EXIT_FAILURE);
}
// '/' + '-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(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s-YYYY-mm-dd\n",outdir,splitprefix);
exit(EXIT_FAILURE);
}
arq="/var/log/squid/access.log";
if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),arq);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arq);
exit(EXIT_FAILURE);
}
time(&min_tt);
while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s\"\n"),arq);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),arq);
exit(EXIT_FAILURE);
}
tt=atoi(data);
prev_month=t->tm_mon;
prev_day=t->tm_mday;
if (fp_ou && fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),output_file,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%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(_("Cannot open file \"%s\": %s\n"),output_file,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),output_file,strerror(errno));
exit(EXIT_FAILURE);
}
if (tt<min_tt) min_tt=tt;
longline_destroy(&line);
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
if (autosplit && fp_ou) {
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),output_file,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),output_file,strerror(errno));
exit(EXIT_FAILURE);
}
}
struct generalitemstruct item;
if(Privacy) {
- if (debugz>=LogLevel_Process) debugaz(_("Top sites report not produced because privacy option is on\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("Top sites report not produced because privacy option is on\n"));
return;
}
if (debugz>=LogLevel_Process)
- debuga(_("Creating top sites report...\n"));
+ debuga(__FILE__,__LINE__,_("Creating top sites report...\n"));
sprintf(general,"%s/sarg-general",outdirname);
sprintf(sites,"%s/sarg-sites",outdirname);
sprintf(report,"%s/topsites.html",outdirname);
if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
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(general2,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),general2,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(general3,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),general3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),general3,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),general2);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),general2);
exit(EXIT_FAILURE);
}
ourl_size=url_len+1;
ourl=realloc(ourl,ourl_size);
if (!ourl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
ourl_size=url_len+1;
ourl=realloc(ourl,ourl_size);
if (!ourl) {
- debuga(_("Not enough memory to store the url\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
exit(EXIT_FAILURE);
}
}
#endif
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),general2,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),general3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),general3,strerror(errno));
exit(EXIT_FAILURE);
}
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (ttnacc!=globstat.nacc || ttnbytes!=globstat.nbytes || ttntime!=globstat.elap) {
- debuga(_("Total statistics mismatch when reading \"%s\" to produce the top sites\n"),general2);
+ debuga(__FILE__,__LINE__,_("Total statistics mismatch when reading \"%s\" to produce the top sites\n"),general2);
exit(EXIT_FAILURE);
}
#endif
if (!KeepTempLog && unlink(general2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (snprintf(csort,sizeof(csort),"sort -t \"\t\" %s -n %s -o \"%s\" \"%s\"",sortt,sortf,sites,general3)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general3,sites);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general3,sites);
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(sites,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),sites,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),sites,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(general3)) {
- debuga(_("Cannot delete \"%s\": %s\n"),general3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),general3,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(report,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
ntopsites = 0;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),sites);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),sites);
exit(EXIT_FAILURE);
}
while(regs<TopSitesNum && (buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf);
if (getword_atoll(&nacc,&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),sites);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),sites);
exit(EXIT_FAILURE);
}
if (nacc == 0) continue;
if (getword_atoll(&nbytes,&gwarea,'\t')<0 || getword_atoll(&ntime,&gwarea,'\t')<0) {
- debuga(_("Invalid record in file \"%s\"\n"),sites);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),sites);
exit(EXIT_FAILURE);
}
if (getword_atoi(&nusers,&gwarea,'\t')<0) {
- debuga(_("Invalid number of users in file \"%s\"\n"),sites);
+ debuga(__FILE__,__LINE__,_("Invalid number of users in file \"%s\"\n"),sites);
exit(EXIT_FAILURE);
}
if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
- debuga(_("Invalid url in file \"%s\"\n"),sites);
+ debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),sites);
exit(EXIT_FAILURE);
}
fprintf(fp_ou,">%s</td></tr>\n",fixnum(nusers,1));
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),sites,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),sites,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(tusr,sizeof(tusr),"%s/sarg-users",outdirname);
if((fp_ou=fopen(tusr,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tusr,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tusr,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"%d\n",totuser);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),tusr,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),tusr,strerror(errno));
exit(EXIT_FAILURE);
}
globstat.totuser=totuser;
struct userinfostruct *uinfo;
if (debugz>=LogLevel_Process)
- debuga(_("Creating top users report...\n"));
+ debuga(__FILE__,__LINE__,_("Creating top users report...\n"));
ntopuser = 0;
snprintf(wger,sizeof(wger),"%s/sarg-general",outdirname);
if((fp_in=fopen(wger,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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(_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
totuser=0;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),wger);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wger);
exit(EXIT_FAILURE);
}
tnoucache+=item.oucache;
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wger,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
ttnoucache+=tnoucache;
}
if (fclose(fp_top2)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (ttnacc!=globstat.nacc || ttnbytes!=globstat.nbytes || ttnelap!=globstat.elap ||
ttnincache!=globstat.incache || ttnoucache!=globstat.oucache) {
- debuga(_("Total statistics mismatch when reading \"%s\" to produce the top users\n"),wger);
+ debuga(__FILE__,__LINE__,_("Total statistics mismatch when reading \"%s\" to produce the top users\n"),wger);
exit(EXIT_FAILURE);
}
#endif
snprintf(top1,sizeof(top1),"%s/top",outdirname);
if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" %s %s -o \"%s\" \"%s\"", tmp, order, sfield, top1, top2)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
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_top1=fopen(top1,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(top2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(top3,sizeof(top3),"%s/"INDEX_HTML_FILE,outdirname);
if((fp_top3=fopen(top3,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
fputs("</body>\n</html>\n",fp_top3);
if (fclose (fp_top3)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
- if (debugz>=LogLevel_Process) debugaz(_("No top users report because it is not configured in report_type\n"));
+ if (debugz>=LogLevel_Process) debugaz(__FILE__,__LINE__,_("No top users report because it is not configured in report_type\n"));
return;
}
ntopuser = 0;
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
while((warea=longline_read(fp_top1,line))!=NULL) {
getword_start(&gwarea,warea);
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("Invalid user in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
- debuga(_("Invalid number of bytes in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nacc,&gwarea,'\t')<0) {
- debuga(_("Invalid number of accesses in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&elap,&gwarea,'\t')<0) {
- debuga(_("Invalid elapsed time in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&incac,&gwarea,'\t')<0) {
- debuga(_("Invalid in-cache size in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid in-cache size in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&oucac,&gwarea,'\n')<0) {
- debuga(_("Invalid out-of-cache size in file \"%s\"\n"),top1);
+ debuga(__FILE__,__LINE__,_("Invalid out-of-cache size in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if(nacc < 1)
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file \"%s\"\n"),user,top1);
+ debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,top1);
exit(EXIT_FAILURE);
}
uinfo->topuser=1;
fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc,ouperc);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if ((inperc!=0. || ouperc!=0.) && fabs(inperc+ouperc-100.)>=0.01) {
- debuga(_("The total of the in-cache and cache-miss is not 100%% at position %d (user %s)\n"),posicao,uinfo->label);
+ debuga(__FILE__,__LINE__,_("The total of the in-cache and cache-miss is not 100%% at position %d (user %s)\n"),posicao,uinfo->label);
}
#endif
}
topcount++;
}
if (fclose(fp_top1)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(top1)) {
- debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
fprintf(fp_top3,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",inperc,ouperc);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (fabs(inperc+ouperc-100.)>=0.01) {
- debuga(_("The total of the in-cache and cache-miss is not 100%%\n"));
+ debuga(__FILE__,__LINE__,_("The total of the in-cache and cache-miss is not 100%%\n"));
}
#endif
}
fputs("</table></div>\n",fp_top3);
write_html_trailer(fp_top3);
if (fclose(fp_top3)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
ddata=(DayObject)malloc(sizeof(*ddata));
if (!ddata)
{
- debuga(_("Not enough memory to store the daily statistics\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the daily statistics\n"));
exit(EXIT_FAILURE);
}
if (!ddata) return;
if (sscanf(date,"%d/%d/%d",&day,&month,&year)!=3) {
- debuga(_("Invalid date \"%s\" for the hourly statistics\n"),date);
+ debuga(__FILE__,__LINE__,_("Invalid date \"%s\" for the hourly statistics\n"),date);
exit(EXIT_FAILURE);
}
if (day<1 || day>31 || month<1 || month>12 || year>9999) {
- debuga(_("Invalid date component in \"%s\" for the hourly statistics\n"),date);
+ debuga(__FILE__,__LINE__,_("Invalid date component in \"%s\" for the hourly statistics\n"),date);
exit(EXIT_FAILURE);
}
hour=atoi(time);
if (hour<0 || hour>=24) {
- debuga(_("Invalid hour %d for the hourly statistics\n"),hour);
+ debuga(__FILE__,__LINE__,_("Invalid hour %d for the hourly statistics\n"),hour);
exit(EXIT_FAILURE);
}
daynum=(year*10000)+(month*100)+day;
if (dayidx<0) {
dayidx=ddata->ndaylist++;
if (dayidx>=sizeof(ddata->daylist)/sizeof(*ddata->daylist)) {
- debuga(_("Too many different dates for the hourly statistics\n"));
+ debuga(__FILE__,__LINE__,_("Too many different dates for the hourly statistics\n"));
exit(EXIT_FAILURE);
}
ddata->daylist[dayidx]=daynum;
if (!ddata) return;
if (snprintf(arqout,sizeof(arqout),"%s/%s.day",tmp,uinfo->filename)>=sizeof(arqout)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s%s\n",tmp,uinfo->filename,".day");
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(arqout,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
if (ddata->bytes[i]==0 && ddata->elap[i]==0) continue;
dayidx=i/24;
if (dayidx>=sizeof(ddata->daylist)/sizeof(*ddata->daylist)) {
- debuga(_("Invalid day index found in the hourly statistics\n"));
+ debuga(__FILE__,__LINE__,_("Invalid day index found in the hourly statistics\n"));
exit(EXIT_FAILURE);
}
hour=i%24;
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
return;
if (KeepTempLog) return;
if (snprintf(arqout,sizeof(arqout),"%s/%s.day",tmp,uinfo->filename)>=sizeof(arqout)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s%s\n",tmp,uinfo->filename,".day");
exit(EXIT_FAILURE);
}
if (unlink(arqout))
- debuga(_("Cannot delete \"%s\": %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqout,strerror(errno));
}
NameEnd=++str;
while (str<next && (unsigned char)*str>' ') {
if (*str=='*') {
- debuga(_("Host name alias \"%s*%s\" contains too many wildcards (*)\n"),NameBegin,NameEnd);
+ debuga(__FILE__,__LINE__,_("Host name alias \"%s*%s\" contains too many wildcards (*)\n"),NameBegin,NameEnd);
return(-1);
}
str++;
}
NameEndE=str;
if (NameEnd==NameEndE) {
- debuga(_("Host name alias \"%*s\" must not end with a wildcard\n"),(int)(next-name),name);
+ debuga(__FILE__,__LINE__,_("Host name alias \"%*s\" must not end with a wildcard\n"),(int)(next-name),name);
return(-1);
}
} else {
len=(int)(NameBeginE-NameBegin);
tmp=malloc(len+1);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
memcpy(tmp,NameBegin,len);
tmp=malloc(len+1);
if (!tmp) {
if (NameBegin) free((void*)NameBegin);
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
memcpy(tmp,NameEnd,len);
if (!new_alias) {
if (NameBegin) free((void*)NameBegin);
if (NameEnd) free((void*)NameEnd);
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
new_alias->MinLen=0;
len=(int)(ReplaceE-Replace);
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
tmp[0]=ALIAS_PREFIX;
} else {
tmp=malloc(new_alias->MinLen+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
tmp[0]=ALIAS_PREFIX;
// insert into the list
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
memcpy(new_alias->Ip,ipv4,4);
len=(int)(ReplaceE-Replace);
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
tmp[0]=ALIAS_PREFIX;
} else {
tmp=malloc(5*4+1);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
sprintf(tmp,"%c%d.%d.%d.%d/%d",ALIAS_PREFIX,ipv4[0],ipv4[1],ipv4[2],ipv4[3],nbits);
// insert into the list
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
memcpy(new_alias->Ip,ipv6,8*sizeof(unsigned short int));
len=ReplaceE-Replace;
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
tmp[0]=ALIAS_PREFIX;
} else {
tmp=malloc(5*8+5);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
sprintf(tmp,"%c%x:%x:%x:%x:%x:%x:%x:%x/%d",ALIAS_PREFIX,ipv6[0],ipv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits);
for (End=buf ; *End && *End!=Delimiter ; End++) {
if (*End=='\\') {
if (End[1]=='\0') {
- debuga(_("Invalid NUL character found in regular expression\n"));
+ debuga(__FILE__,__LINE__,_("Invalid NUL character found in regular expression\n"));
return(-1);
}
End++; //ignore the escaped character
}
}
if (*End!=Delimiter) {
- debuga(_("Unterminated regular expression\n"));
+ debuga(__FILE__,__LINE__,_("Unterminated regular expression\n"));
return(-1);
}
*End++='\0';
// store it
new_alias=malloc(sizeof(*new_alias));
if (!new_alias) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
return(-1);
}
new_alias->Next=NULL;
new_alias->Re=pcre_compile(buf,0,&PcreError,&ErrorOffset,NULL);
if (new_alias->Re==NULL) {
- debuga(_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
+ debuga(__FILE__,__LINE__,_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
free(new_alias);
return(-1);
}
len=strlen(Replace);
tmp=malloc(len+2);
if (!tmp) {
- debuga(_("Not enough memory to store the host name aliasing directives\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
pcre_free(new_alias->Re);
return(-1);
}
return(-1);
return(0);
#else
- debuga(_("PCRE not compiled in therefore the regular expressions are not available in the host alias file\n"));
+ debuga(__FILE__,__LINE__,_("PCRE not compiled in therefore the regular expressions are not available in the host alias file\n"));
return(-1);
#endif
}
longline line;
char *buf;
- if (debug) debuga(_("Reading host alias file \"%s\"\n"),Filename);
+ if (debug) debuga(__FILE__,__LINE__,_("Reading host alias file \"%s\"\n"),Filename);
fi=fopen(Filename,"rt");
if (!fi) {
- debuga(_("Cannot read host name alias file \"%s\": %s\n"),Filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot read host name alias file \"%s\": %s\n"),Filename,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),Filename);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),Filename);
exit(EXIT_FAILURE);
}
while ((buf=longline_read(fi,line)) != NULL) {
if (Alias_Store(buf)<0) {
- debuga(_("While reading \"%s\"\n"),Filename);
+ debuga(__FILE__,__LINE__,_("While reading \"%s\"\n"),Filename);
exit(EXIT_FAILURE);
}
}
longline_destroy(&line);
if (fclose(fi)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
exit(EXIT_FAILURE);
}
struct hostalias_ipv4 *alias4;
struct hostalias_ipv6 *alias6;
- debuga(_("List of host names to alias:\n"));
+ debuga(__FILE__,__LINE__,_("List of host names to alias:\n"));
for (alias1=FirstAliasName ; alias1 ; alias1=alias1->Next) {
if (alias1->HostName_Prefix && alias1->HostName_Suffix)
- debuga(_(" %s*%s => %s\n"),alias1->HostName_Prefix,alias1->HostName_Suffix,alias1->Alias);
+ debuga(__FILE__,__LINE__,_(" %s*%s => %s\n"),alias1->HostName_Prefix,alias1->HostName_Suffix,alias1->Alias);
else if (alias1->HostName_Prefix)
- debuga(_(" %s => %s\n"),alias1->HostName_Prefix,alias1->Alias);
+ debuga(__FILE__,__LINE__,_(" %s => %s\n"),alias1->HostName_Prefix,alias1->Alias);
else
- debuga(_(" *%s => %s\n"),alias1->HostName_Suffix,alias1->Alias);
+ debuga(__FILE__,__LINE__,_(" *%s => %s\n"),alias1->HostName_Suffix,alias1->Alias);
}
for (alias4=FirstAliasIpv4 ; alias4 ; alias4=alias4->Next) {
- debuga(_(" %d.%d.%d.%d/%d => %s\n"),alias4->Ip[0],alias4->Ip[1],alias4->Ip[2],alias4->Ip[3],alias4->NBits,alias4->Alias);
+ debuga(__FILE__,__LINE__,_(" %d.%d.%d.%d/%d => %s\n"),alias4->Ip[0],alias4->Ip[1],alias4->Ip[2],alias4->Ip[3],alias4->NBits,alias4->Alias);
}
for (alias6=FirstAliasIpv6 ; alias6 ; alias6=alias6->Next) {
- debuga(_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias6->Ip[0],alias6->Ip[1],alias6->Ip[2],alias6->Ip[3],
+ debuga(__FILE__,__LINE__,_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias6->Ip[0],alias6->Ip[1],alias6->Ip[2],alias6->Ip[3],
alias6->Ip[4],alias6->Ip[5],alias6->Ip[6],alias6->Ip[7],alias6->NBits,alias6->Alias);
}
}
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(_("Invalid record in file \"%s\"\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(_("Invalid date in file \"%s\"\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(_("Invalid useragent in file \"%s\"\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(_("Invalid record in file \"%s\"\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(_("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(_("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(_("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(_("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(_("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(_("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);
}
if (!UserStrings) {
UserStrings=StringBuffer_Create();
if (!UserStrings) {
- debuga(_("Not enough memory to store the user's strings\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user's strings\n"));
exit(EXIT_FAILURE);
}
}
if (!group) {
group=malloc(sizeof(*group));
if (!group) {
- debuga(_("Not enough memory to store user \"%s\"\n"),userid);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store user \"%s\"\n"),userid);
exit(EXIT_FAILURE);
}
memset(group,0,sizeof(*group));
user->id=StringBuffer_Store(UserStrings,userid);
if (!user->id) {
- debuga(_("Not enough memory to store user ID \"%s\"\n"),userid);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store user ID \"%s\"\n"),userid);
exit(EXIT_FAILURE);
}
user->label=user->id; //assign a label to avoid a NULL pointer in case none is provided
user->filename=StringBuffer_Store(UserStrings,filename);
if (!user->filename)
{
- debuga(_("Not enough memory to store the file name for user \"%s\"\n"),user->id);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the file name for user \"%s\"\n"),user->id);
exit(EXIT_FAILURE);
}
if (!UserStrings) return;
uinfo->label=StringBuffer_Store(UserStrings,label);
if (!uinfo->label) {
- debuga(_("Not enough memory to store label \"%s\" of user \"%s\"\n"),label,uinfo->id);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store label \"%s\" of user \"%s\"\n"),label,uinfo->id);
exit(EXIT_FAILURE);
}
}
longline line;
char *buf;
- if (debug) debuga(_("Reading user alias file \"%s\"\n"),Filename);
+ if (debug) debuga(__FILE__,__LINE__,_("Reading user alias file \"%s\"\n"),Filename);
UserAliases=Alias_Create();
if (!UserAliases) {
- debuga(_("Cannot store user's aliases\n"));
+ debuga(__FILE__,__LINE__,_("Cannot store user's aliases\n"));
exit(EXIT_FAILURE);
}
fi=fopen(Filename,"rt");
if (!fi) {
- debuga(_("Cannot read user name alias file \"%s\": %s\n"),Filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot read user name alias file \"%s\": %s\n"),Filename,strerror(errno));
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),Filename);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),Filename);
exit(EXIT_FAILURE);
}
while ((buf=longline_read(fi,line)) != NULL) {
if (Alias_Store(UserAliases,buf)<0) {
- debuga(_("While reading \"%s\"\n"),Filename);
+ debuga(__FILE__,__LINE__,_("While reading \"%s\"\n"),Filename);
exit(EXIT_FAILURE);
}
}
longline_destroy(&line);
if (fclose(fi)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
exit(EXIT_FAILURE);
}
if (debug) {
- debuga(_("List of user names to alias:\n"));
+ debuga(__FILE__,__LINE__,_("List of user names to alias:\n"));
Alias_PrintList(UserAliases);
}
}
int z1, z2;
if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),UserTabFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
if (fseek(fp_usr, 0, SEEK_END)==-1) {
- debuga(_("Failed to move till the end of file \"%s\": %s\n"),UserTabFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to move till the end of file \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
nreg = ftell(fp_usr);
if (nreg<0) {
- debuga(_("Cannot get the size of file \"%s\"\n"),UserTabFile);
+ debuga(__FILE__,__LINE__,_("Cannot get the size of file \"%s\"\n"),UserTabFile);
exit(EXIT_FAILURE);
}
nreg += 100;
if (fseek(fp_usr, 0, SEEK_SET)==-1) {
- debuga(_("Failed to rewind file \"%s\": %s\n"),UserTabFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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(__FILE__,__LINE__,_("ERROR: Cannot load. Memory fault\n"));
exit(EXIT_FAILURE);
}
userfile[0]='\t';
z1=0;
while(buf[z1] && (unsigned char)buf[z1]>' ') {
if (z2+3>=nreg) { //need at least 3 additional bytes for the minimum string "\n\t\0"
- debuga(_("The list of users is too long in file \"%s\"\n"),UserTabFile);
+ debuga(__FILE__,__LINE__,_("The list of users is too long in file \"%s\"\n"),UserTabFile);
exit(EXIT_FAILURE);
}
userfile[z2++]=buf[z1++];
userfile[z2++]='\n';
while(buf[z1] && (unsigned char)buf[z1]>=' ') {
if (z2+2>=nreg) { //need at least 2 additional bytes for "\t\0"
- debuga(_("The list of users is too long in file \"%s\"\n"),UserTabFile);
+ debuga(__FILE__,__LINE__,_("The list of users is too long in file \"%s\"\n"),UserTabFile);
exit(EXIT_FAILURE);
}
userfile[z2++]=buf[z1++];
}
userfile[z2]='\0';
if (fclose(fp_usr)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),UserTabFile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
}
url.lud_scope = LDAP_SCOPE_DEFAULT;
ldapuri = ldap_url_desc2str(&url);
if (ldapuri==NULL) {
- debuga(_("Cannot prepare ldap URI for server %s on port %d\n"),LDAPHost,LDAPPort);
+ debuga(__FILE__,__LINE__,_("Cannot prepare ldap URI for server %s on port %d\n"),LDAPHost,LDAPPort);
exit(EXIT_FAILURE);
}
rc = ldap_initialize(&ldap_handle, ldapuri);
if (rc != LDAP_SUCCESS) {
- debuga(_("Unable to connect to LDAP server %s on port %d: %d (%s)\n"), LDAPHost, LDAPPort, rc, ldap_err2string(rc));
+ debuga(__FILE__,__LINE__,_("Unable to connect to LDAP server %s on port %d: %d (%s)\n"), LDAPHost, LDAPPort, rc, ldap_err2string(rc));
exit(EXIT_FAILURE);
}
ldap_memfree(ldapuri);
if (ldap_set_option(ldap_handle, LDAP_OPT_REFERRALS, LDAP_OPT_OFF) != LDAP_OPT_SUCCESS) {
- debuga(_("Could not disable LDAP_OPT_REFERRALS\n"));
+ debuga(__FILE__,__LINE__,_("Could not disable LDAP_OPT_REFERRALS\n"));
exit(EXIT_FAILURE);
}
int ldap_protocol_version = LDAPProtocolVersion;
if (ldap_set_option(ldap_handle, LDAP_OPT_PROTOCOL_VERSION, &ldap_protocol_version) != LDAP_SUCCESS) {
- debuga(_("Could not set LDAP protocol version %d\n"), ldap_protocol_version);
+ debuga(__FILE__,__LINE__,_("Could not set LDAP protocol version %d\n"), ldap_protocol_version);
exit(EXIT_FAILURE);
}
/* Bind to the LDAP server. */
rc = ldap_simple_bind_s( ldap_handle, LDAPBindDN, LDAPBindPW );
if ( rc != LDAP_SUCCESS ) {
- debuga(_("Cannot bind to LDAP server: %s\n"), ldap_err2string(rc));
+ debuga(__FILE__,__LINE__,_("Cannot bind to LDAP server: %s\n"), ldap_err2string(rc));
exit(EXIT_FAILURE);
}
if (LDAPNativeCharset[0]!='\0') {
ldapiconv = iconv_open( LDAPNativeCharset, "UTF-8" );
if (ldapiconv==(iconv_t)-1) {
- debuga(_("iconv cannot convert from UTF-8 to %s: %s\n"),LDAPNativeCharset,strerror(errno));
+ debuga(__FILE__,__LINE__,_("iconv cannot convert from UTF-8 to %s: %s\n"),LDAPNativeCharset,strerror(errno));
exit(EXIT_FAILURE);
}
}
ldapconvbuffersize=str_out_len;
str_out = realloc(ldapconvbuffer,ldapconvbuffersize);
if (!str_out) {
- debuga(_("Not enough memory to convert a LDAP returned string: %lu bytes required\n"),(unsigned long int)str_out_len);
+ debuga(__FILE__,__LINE__,_("Not enough memory to convert a LDAP returned string: %lu bytes required\n"),(unsigned long int)str_out_len);
exit(EXIT_FAILURE);
}
ldapconvbuffer = str_out;
return_value = iconv(ldapiconv, (ICONV_CONST char **)&str_in, &str_in_len, &str_out, &str_out_len );
if ( return_value == ( size_t ) -1 ) {
/* TRANSLATORS: The message is followed by the reason for the failure. */
- debuga(_("iconv failed on string \"%s\":\n"),str_in_orig);
+ debuga(__FILE__,__LINE__,_("iconv failed on string \"%s\":\n"),str_in_orig);
switch ( errno ) {
/* See "man 3 iconv" for an explanation. */
case EILSEQ:
- debuga(_("Invalid multibyte sequence.\n"));
+ debuga(__FILE__,__LINE__,_("Invalid multibyte sequence.\n"));
break;
case EINVAL:
- debuga(_("Incomplete multibyte sequence.\n"));
+ debuga(__FILE__,__LINE__,_("Incomplete multibyte sequence.\n"));
break;
case E2BIG:
- debuga(_("No more room.\n"));
+ debuga(__FILE__,__LINE__,_("No more room.\n"));
break;
default:
- debuga(_("Error: %s.\n"),strerror( errno ));
+ debuga(__FILE__,__LINE__,_("Error: %s.\n"),strerror( errno ));
}
exit(EXIT_FAILURE);
}
attrs[1]=NULL;
rc= ldap_search_ext_s(ldap_handle, LDAPBaseSearch, LDAP_SCOPE_SUBTREE, filtersearch, attrs, 0, NULL, NULL, NULL, -1, &result);
if (rc != LDAP_SUCCESS) {
- debuga(_("LDAP search failed: %s\nlooking for \"%s\" at or below \"%s\"\n"), ldap_err2string(rc),filtersearch,LDAPBaseSearch);
+ debuga(__FILE__,__LINE__,_("LDAP search failed: %s\nlooking for \"%s\" at or below \"%s\"\n"), ldap_err2string(rc),filtersearch,LDAPBaseSearch);
safe_strcpy(mappedname,userlogin,namelen);
return;
}
if (strcmp(UserTabFile, "ldap") == 0) {
if(debug) {
/* TRANSLATORS: The %s may be the string "ldap" or a file name.*/
- debuga(_("Loading User table from \"%s\"\n"),UserTabFile);
+ debuga(__FILE__,__LINE__,_("Loading User table from \"%s\"\n"),UserTabFile);
}
#ifdef HAVE_LDAP_H
which_usertab=UTT_Ldap;
init_ldap_usertab();
#else
- debuga(_("LDAP module not compiled in sarg\n"));
+ debuga(__FILE__,__LINE__,_("LDAP module not compiled in sarg\n"));
exit(EXIT_FAILURE);
#endif //HAVE_LDAP_H
} else if (UserTabFile[0] != '\0') {
if(debug)
- debuga(_("Loading User table from \"%s\"\n"),UserTabFile);
+ debuga(__FILE__,__LINE__,_("Loading User table from \"%s\"\n"),UserTabFile);
which_usertab=UTT_File;
init_file_usertab(UserTabFile);
} else {
if (n<=0) return;
calls=backtrace_symbols(buffer,n);
if (calls) {
- debuga(_("getword backtrace:\n"));
+ debuga(__FILE__,__LINE__,_("getword backtrace:\n"));
for (i=0 ; i<n ; i++) {
fprintf(stderr,"SARG: %d:%s\n",i+1,calls[i]);
}
void getword_restart(struct getwordstruct *gwarea)
{
if (gwarea->modified) {
- debuga(_("Cannot parse again the line as it was modified\n"));
+ debuga(__FILE__,__LINE__,_("Cannot parse again the line as it was modified\n"));
exit(EXIT_FAILURE);
}
gwarea->current=gwarea->beginning;
TRANSLATORS: The %s is the name of the function reporting the
error message.
*/
- debuga(_("End of word not found 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);
+ debuga(__FILE__,__LINE__,_("End of word not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
word[(limit>0) ? limit-1 : 0]='\0';
#if USE_GETWORD_BACKTRACE
getword_backtrace();
for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) {
if(x>=limit) {
- debuga(_("End of word not found 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);
+ debuga(__FILE__,__LINE__,_("End of word not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
if (limit>0) word[limit-1]='\0';
#if USE_GETWORD_BACKTRACE
getword_backtrace();
for(x=0;(gwarea->current[x] && (gwarea->current[x] != stop ));x++) {
if(x>=limit) {
- debuga(_("End of word not found 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);
+ debuga(__FILE__,__LINE__,_("End of word not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
TRANSLATORS: The first %s is the function name (in the source code) where the
overflow is detected.
*/
- debuga(_("Integer overflow detected in %s in line %s\n"),__func__,gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Integer overflow detected in %s in line %s\n"),__func__,gwarea->beginning);
return(-1);
}
*number=(*number * 10) + digit;
/*
TRANSLATORS: The %s is the function name, in the source code, where the problem occured.
*/
- debuga(_("End of number not found 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);
+ debuga(__FILE__,__LINE__,_("End of number not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
for(x=0;isdigit(gwarea->current[x]);x++) {
digit=gwarea->current[x]-'0';
if (*number > (INT_MAX-digit)/10) {
- debuga(_("Integer overflow detected in %s in line %s\n"),__func__,gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("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(_("End of number not found 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);
+ debuga(__FILE__,__LINE__,_("End of number not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
for(x=0;isdigit(gwarea->current[x]);x++) {
digit=gwarea->current[x]-'0';
if (*number > (LONG_MAX-digit)/10) {
- debuga(_("Integer overflow detected in %s in line %s\n"),__func__,gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("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(_("End of number not found 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);
+ debuga(__FILE__,__LINE__,_("End of number not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
int digit;
if (gwarea->current[0] == '-') {
- debuga(_("getword_atolu got a negative number.\n"));
- debuga(_("Line=\"%s\"\n"),gwarea->beginning);
- debuga(_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("getword_atolu got a negative number.\n"));
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
return(-1);
}
if (gwarea->current[0] == '+') {
for(x=0;isdigit(gwarea->current[x]);x++) {
digit=gwarea->current[x]-'0';
if (*number > (ULONG_MAX-digit)/10) {
- debuga(_("Integer overflow detected in %s in line %s\n"),__func__,gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("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(_("End of number not found 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);
+ debuga(__FILE__,__LINE__,_("End of number not found in %s after %d bytes.\n"),__func__,x);
+ debuga(__FILE__,__LINE__,_("Line=\"%s\"\n"),gwarea->beginning);
+ debuga(__FILE__,__LINE__,_("Record=\"%s\"\n"),gwarea->current);
+ debuga(__FILE__,__LINE__,_("searching for \'x%x\'\n"),stop);
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
int start;
if (orig_line && orig_line!=gwarea->beginning) {
- debuga(_("Invalid buffer passed to getword_ptr\n"));
+ debuga(__FILE__,__LINE__,_("Invalid buffer passed to getword_ptr\n"));
return(-1);
}
int chars;
if(!is_absolute(name)) {
- debuga(_("Invalid path (%s). Please, use absolute paths only.\n"),name);
+ debuga(__FILE__,__LINE__,_("Invalid path (%s). Please, use absolute paths only.\n"),name);
exit(EXIT_FAILURE);
}
chars=0;
for (i=0 ; name[i] ; i++) {
if (i>=sizeof(w0)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s\n",name);
exit(EXIT_FAILURE);
}
w0[i] = '\0';
if (access(w0, R_OK) != 0) {
if (PortableMkDir(w0,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),w0,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),w0,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (access(name, R_OK) != 0) {
if (PortableMkDir(name,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),name,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),name,strerror(errno));
exit(EXIT_FAILURE);
}
}
ssize--;
if (len>ssize) {
- debuga(_("The requested number of digits passed to my_lltoa (%d) is bigger than the output buffer size (%d)\n"),len,ssize);
+ debuga(__FILE__,__LINE__,_("The requested number of digits passed to my_lltoa (%d) is bigger than the output buffer size (%d)\n"),len,ssize);
abort();
}
\param msg The printf like message to format.
\param ... The arguments to format in the message.
*/
-void debuga(const char *msg,...)
+void debuga(const char *File,int Line,const char *msg,...)
{
va_list ap;
- fputs(_("SARG: "),stderr);
+ if (debugz>=LogLevel_Source) {
+ /* The path is removed because every source file is in the same directory.
+ * There is no point in reporting the full path from the build directory.
+ */
+ const char *ptr=strrchr(File,'/');
+ if (!ptr) ptr=File;
+ /* TRANSLATORS: This is the prefix to stderr messages when the debug level is
+ set to display the source file (%s) and the line number (%d). */
+ fprintf(stderr,_("SARG(%s:%d): "),ptr,Line);
+ } else {
+ /* TRANSLATORS: This is the prefix to stderr messages when the debug level
+ is low. */
+ fputs(_("SARG: "),stderr);
+ }
va_start(ap,msg);
vfprintf(stderr,msg,ap);
va_end(ap);
\param msg The printf like message to format.
\param ... The arguments to format in the message.
*/
-void debugaz(const char *msg,...)
+void debugaz(const char *File,int Line,const char *msg,...)
{
va_list ap;
- fputs(_("SARG: (info) "),stderr);
+ if (debugz>=LogLevel_Source) {
+ /* The path is removed because every source file is in the same directory.
+ * There is no point in reporting the full path from the build directory.
+ */
+ const char *ptr=strrchr(File,'/');
+ if (!ptr) ptr=File;
+ /* TRANSLATORS: This is the prefix to information messages when the debug level is
+ set to display the source file (%s) and the line number (%d). */
+ fprintf(stderr,_("SARG(%s:%d): (info) "),ptr,Line);
+ } else {
+ /* TRANSLATORS: This is the prefix to information messages when the debug level
+ is low. */
+ fputs(_("SARG: (info) "),stderr);
+ }
va_start(ap,msg);
vfprintf(stderr,msg,ap);
va_end(ap);
char wdir[MAXLEN];
if (snprintf(wdir,sizeof(wdir),"%s%s/sarg-date",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/sarg-date",dirname,name);
exit(EXIT_FAILURE);
}
if ((fp_in = fopen(wdir, "rt")) == 0) {
if (snprintf(wdir,sizeof(wdir),"%s%s/date",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/date",dirname,name);
exit(EXIT_FAILURE);
}
}
if (!fgets(data,80,fp_in)) {
- debuga(_("Failed to read the date in file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Failed to read the date in file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(data);
int nuser;
if (snprintf(wdir,sizeof(wdir),"%s%s/sarg-users",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/sarg-users",dirname,name);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(wdir,"r"))==NULL) {
if (snprintf(wdir,sizeof(wdir),"%s%s/users",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/users",dirname,name);
exit(EXIT_FAILURE);
}
}
if (!fgets(tuser,sizeof(tuser),fp_in)) {
- debuga(_("Failed to read the number of users in file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Failed to read the number of users in file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
exit(EXIT_FAILURE);
}
nuser=atoi(tuser);
*media=0;
if (snprintf(wdir,sizeof(wdir),"%s%s/sarg-general",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/sarg-general",dirname,name);
exit(EXIT_FAILURE);
}
if ((fp_in = fopen(wdir, "r")) == 0) {
if (snprintf(wdir,sizeof(wdir),"%s%s/general",dirname,name)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s%s/general",dirname,name);
exit(EXIT_FAILURE);
}
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
continue;
getword_start(&gwarea,buf);
if (getword(user,sizeof(user),&gwarea,sep)<0) {
- debuga(_("Invalid user in file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Invalid user in file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
if(strcmp(user,"TOTAL") != 0)
continue;
if (getword_skip(MAXLEN,&gwarea,sep)<0) {
- debuga(_("Invalid total number of accesses in file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Invalid total number of accesses in file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
if (getword_atoll(tbytes,&gwarea,sep)<0) {
- debuga(_("Invalid number of bytes in file \"%s\"\n"),wdir);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),wdir);
exit(EXIT_FAILURE);
}
break;
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
exit(EXIT_FAILURE);
}
longline_destroy(&line);
struct stat info;
if (snprintf(images,sizeof(images),"%simages",outdir)>=sizeof(images)) {
- debuga(_("Cannot copy images to target directory %simages\n"),outdir);
+ debuga(__FILE__,__LINE__,_("Cannot copy images to target directory %simages\n"),outdir);
exit(EXIT_FAILURE);
}
if (access(images,R_OK)!=0) {
if (PortableMkDir(images,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),images,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),images,strerror(errno));
exit(EXIT_FAILURE);
}
}
dirp = opendir(ImageDir);
if(dirp==NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),ImageDir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),ImageDir,strerror(errno));
return;
}
while ((direntp = readdir( dirp )) != NULL ){
if(direntp->d_name[0]=='.')
continue;
if (snprintf(srcfile,sizeof(srcfile),"%s/%s",ImageDir,direntp->d_name)>=sizeof(srcfile)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s/%s",ImageDir,direntp->d_name);
exit(EXIT_FAILURE);
}
if (stat(srcfile,&info)) {
- debuga(_("Cannot stat \"%s\": %s\n"),srcfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"),srcfile,strerror(errno));
continue;
}
if (S_ISREG(info.st_mode)) {
if (snprintf(dstfile,sizeof(dstfile),"%s/%s",images,direntp->d_name)>=sizeof(dstfile)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s/%s",images,direntp->d_name);
exit(EXIT_FAILURE);
}
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(__FILE__,__LINE__,_("Failed to copy image %s to %s\n"),srcfile,dstfile);
break;
}
}
if (fclose(img_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),dstfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),dstfile,strerror(errno));
exit(EXIT_FAILURE);
}
} else
- debuga(_("Cannot open file \"%s\": %s\n"), dstfile, strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"), dstfile, strerror(errno));
if (fclose(img_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),srcfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),srcfile,strerror(errno));
exit(EXIT_FAILURE);
}
} else
- debuga(_("Cannot open file \"%s\": %s\n"), srcfile, strerror(errno));
+ debuga(__FILE__,__LINE__,_("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__,__LINE__,_("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__,__LINE__,_("File %s already exists, moved to %s\n"),dirname2,wdir);
rename(dirname2,wdir);
strcpy(dirname2,wdir);
}
strcpy(dirname2,wdir);
if (snprintf(wdir,sizeof(wdir),"%s/sarg-date",outdirname)>=sizeof(wdir)) {
- debuga(_("Buffer too small to store "));
+ debuga(__FILE__,__LINE__,_("Buffer too small to store "));
debuga_more("%s/sarg-date",outdirname);
exit(EXIT_FAILURE);
}
if ((fp_ou = fopen(wdir, "wt")) == 0) {
- debuga(_("Cannot open file \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%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(__FILE__,__LINE__,_("Failed to write the date in %s\n"),wdir);
perror("SARG:");
exit(EXIT_FAILURE);
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdir,strerror(errno));
exit(EXIT_FAILURE);
}
void safe_strcpy(char *dest,const char *src,int length)
{
if (length<=0) {
- debuga(_("Invalid buffer length passed to the function to safely copy a string\n"));
+ debuga(__FILE__,__LINE__,_("Invalid buffer length passed to the function to safely copy a string\n"));
exit(EXIT_FAILURE);
}
strncpy(dest,src,length-1);
int next=-1;
if (sscanf(date,"%d/%d/%d%n",&d0,&m0,&y0,&next)!=3 || y0<100 || m0<1 || m0>12 || d0<1 || d0>31 || next<0) {
- debuga(_("The date passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
+ debuga(__FILE__,__LINE__,_("The date passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
exit(EXIT_FAILURE);
}
if (date[next]=='-') {
if (sscanf(date+next+1,"%d/%d/%d",&d1,&m1,&y1)!=3 || y1<100 || m1<1 || m1>12 || d1<1 || d1>31) {
- debuga(_("The date range passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
+ debuga(__FILE__,__LINE__,_("The date range passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
exit(EXIT_FAILURE);
}
} else if (date[next]!='\0') {
- debuga(_("The date range passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
+ debuga(__FILE__,__LINE__,_("The date range passed as argument is not formated as dd/mm/yyyy or dd/mm/yyyy-dd/mm/yyyy\n"));
exit(EXIT_FAILURE);
} else {
d1=d0;
struct tm *Date0,Date1;
if (time(&Today)==(time_t)-1) {
- debuga(_("Failed to get the current time\n"));
+ debuga(__FILE__,__LINE__,_("Failed to get the current time\n"));
exit(EXIT_FAILURE);
}
if (sscanf(date,"day-%d",&i)==1) {
if (i<0) {
- debuga(_("Invalid number of days in -d parameter\n"));
+ debuga(__FILE__,__LINE__,_("Invalid number of days in -d parameter\n"));
exit(EXIT_FAILURE);
}
Today-=i*24*60*60;
Date0=localtime(&Today);
if (Date0==NULL) {
- debuga(_("Cannot convert local time: %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot convert local time: %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
y0=y1=Date0->tm_year+1900;
time_t WeekBegin;
if (i<0) {
- debuga(_("Invalid number of weeks in -d parameter\n"));
+ debuga(__FILE__,__LINE__,_("Invalid number of weeks in -d parameter\n"));
exit(EXIT_FAILURE);
}
Date0=localtime(&Today);
if (Date0==NULL) {
- debuga(_("Cannot convert local time: %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot convert local time: %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
WeekBegin=Today-((Date0->tm_wday-FirstWeekDay+7)%7)*24*60*60;
WeekBegin-=i*7*24*60*60;
Date0=localtime(&WeekBegin);
if (Date0==NULL) {
- debuga(_("Cannot convert local time: %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot convert local time: %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
y0=Date0->tm_year+1900;
WeekBegin+=6*24*60*60;
Date0=localtime(&WeekBegin);
if (Date0==NULL) {
- debuga(_("Cannot convert local time: %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot convert local time: %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
y1=Date0->tm_year+1900;
d1=Date0->tm_mday;
} else if (sscanf(date,"month-%d",&i)==1) {
if (i<0) {
- debuga(_("Invalid number of months in -d parameter\n"));
+ debuga(__FILE__,__LINE__,_("Invalid number of months in -d parameter\n"));
exit(EXIT_FAILURE);
}
Date0=localtime(&Today);
if (Date0==NULL) {
- debuga(_("Cannot convert local time: %s\n"),strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot convert local time: %s\n"),strerror(errno));
exit(EXIT_FAILURE);
}
if (Date0->tm_mon<i%12) {
m1=Date0->tm_mon+1;
d1=Date0->tm_mday;
} else {
- debuga(_("Invalid date range passed on command line\n"));
+ debuga(__FILE__,__LINE__,_("Invalid date range passed on command line\n"));
exit(EXIT_FAILURE);
}
}
return;
if(debug) {
- debuga(_("Purging temporary file sarg-general\n"));
+ debuga(__FILE__,__LINE__,_("Purging temporary file sarg-general\n"));
}
if (snprintf(filename,sizeof(filename),"%s/sarg-general",outdir)>=sizeof(filename)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/sarg-period\n",outdir);
exit(EXIT_FAILURE);
}
if((fp_gen=fopen(filename,"w"))==NULL){
- debuga(_("Cannot open file \"%s\": %s\n"),filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),filename,strerror(errno));
exit(EXIT_FAILURE);
}
totalger(fp_gen,filename);
if (fclose(fp_gen)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),filename,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),filename,strerror(errno));
exit(EXIT_FAILURE);
}
}
return;
if((fp_in=fopen(ExcludeCodes,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),ExcludeCodes,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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 file \"%s\": %s\n"),ExcludeCodes,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to move till the end of 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(__FILE__,__LINE__,_("Cannot get the size of file \"%s\"\n"),ExcludeCodes);
exit(EXIT_FAILURE);
}
if (fseek(fp_in, 0, SEEK_SET)==-1) {
- debuga(_("Failed to rewind file \"%s\": %s\n"),ExcludeCodes,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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 bytes required)\n"),MemSize);
+ debuga(__FILE__,__LINE__,_("malloc error (%ld bytes required)\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(__FILE__,__LINE__,_("Too many codes to exclude in file \"%s\"\n"),ExcludeCodes);
break;
}
strcat(excludecode,data);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),ExcludeCodes,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),ExcludeCodes,strerror(errno));
exit(EXIT_FAILURE);
}
return;
(direntp->d_name[1] == '.' && direntp->d_name[2] == '\0')))
continue;
if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",dir,direntp->d_name);
exit(EXIT_FAILURE);
}
err=stat(dname,&st);
#endif
if (err) {
- debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
exit(EXIT_FAILURE);
}
if (S_ISREG(st.st_mode)) {
if (unlink(dname)) {
- debuga(_("Cannot delete \"%s\": %s\n"),dname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),dname,strerror(errno));
exit(EXIT_FAILURE);
}
} else if (S_ISDIR(st.st_mode)) {
unlinkdir(dname,0);
} else {
- debuga(_("Don't know how to delete \"%s\" (not a regular file nor a directory)\n"),dname);
+ debuga(__FILE__,__LINE__,_("Don't know how to delete \"%s\" (not a regular file nor a directory)\n"),dname);
}
}
closedir(dirp);
if (!contentonly) {
if (rmdir(dir)) {
- debuga(_("Cannot delete \"%s\": %s\n"),dir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),dir,strerror(errno));
exit(EXIT_FAILURE);
}
}
if (dlen>=elen && strcasecmp(direntp->d_name+dlen-elen,TmpExt[i])==0) break;
}
if (i<0) {
- debuga(_("Unknown file \"%s\" found in temporary directory \"%s\". It is not one of our files. "
+ debuga(__FILE__,__LINE__,_("Unknown file \"%s\" found in temporary directory \"%s\". It is not one of our files. "
"Please check the temporary directory you gave to sarg. Adjust the path to a safe "
"directory or manually delete the content of \"%s\"\n"),direntp->d_name,dir,dir);
exit(EXIT_FAILURE);
}
if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",dir,direntp->d_name);
exit(EXIT_FAILURE);
}
err=stat(dname,&st);
#endif
if (err) {
- debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
exit(EXIT_FAILURE);
}
if (S_ISDIR(st.st_mode)) {
unlinkdir(dname,0);
} else if (!S_ISREG(st.st_mode)) {
- debuga(_("Unknown path type for \"%s\". Check temporary directory\n"),dname);
+ debuga(__FILE__,__LINE__,_("Unknown path type for \"%s\". Check temporary directory\n"),dname);
exit(EXIT_FAILURE);
}
}
if (dlen>=elen && strcasecmp(direntp->d_name+dlen-elen,TmpExt[i])==0) break;
}
if (i<0) {
- debuga(_("Unknown file \"%s\" found in temporary directory \"%s\". It is not one of our files. "
+ debuga(__FILE__,__LINE__,_("Unknown file \"%s\" found in temporary directory \"%s\". It is not one of our files. "
"Please check the temporary directory you gave to sarg. Adjust the path to a safe "
"directory or manually delete the content of \"%s\"\n"),direntp->d_name,dir,dir);
exit(EXIT_FAILURE);
}
if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",dir,direntp->d_name);
exit(EXIT_FAILURE);
}
err=stat(dname,&st);
#endif
if (err) {
- debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"),dname,strerror(errno));
exit(EXIT_FAILURE);
}
if (S_ISREG(st.st_mode)) {
if (unlink(dname)) {
- debuga(_("Cannot delete \"%s\": %s\n"),dname,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),dname,strerror(errno));
exit(EXIT_FAILURE);
}
} else {
- debuga(_("Don't know how to delete \"%s\" (not a regular file)\n"),dname);
+ debuga(__FILE__,__LINE__,_("Don't know how to delete \"%s\" (not a regular file)\n"),dname);
}
}
closedir(dirp);