/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2012
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
void convlog(const char *arq, char df, int dfrom, int duntil)
{
- FILE *fp_in;
+ FileObject *fp_in;
char *buf;
char data[30];
char dia[11];
if(arq[0] == '\0')
arq="/var/log/squid/access.log";
- if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
- debuga(_("(convlog) Cannot open log file %s: %s\n"),arq,strerror(errno));
+ if((fp_in=FileObject_Open(arq))==NULL) {
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arq,FileObject_GetLastOpenError());
exit(EXIT_FAILURE);
}
if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read the log 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(_("Maybe you have a broken record or garbage 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(_("Failed to close file %s: %s\n"),arq,strerror(errno));
+ if (FileObject_Close(fp_in)) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,FileObject_GetLastCloseError());
exit(EXIT_FAILURE);
}
}