/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2013
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
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)
{
void realtime(void)
{
- FILE *fp;
+ FileObject *fp;
char file_name[2048];
char *buf;
longline line;
init_usertab(UserTabFile);
LogLine_Init(&log_line);
- if ((line=longline_create())==NULL) {
- debuga(_("Not enough memory to read the log file\n"));
- exit(EXIT_FAILURE);
- }
-
/*
* Store one more entry to prepare the memory structure in place and reject it if
* it is about the same user and url as the last stored one.
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");
+ fp = FileObject_Open(file_name);
if (!fp) {
- debuga(_("Failed to open the last modified log file \"%s\": %s\n"),file_name,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),file_name,FileObject_GetLastOpenError());
exit(EXIT_FAILURE);
}
+
+ if ((line=longline_create())==NULL) {
+ debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),file_name);
+ exit(EXIT_FAILURE);
+ }
+
while((buf=longline_read(fp,line)) != NULL )
{
log_entry_status=LogLine_Parse(&log_line,&log_entry,buf);
if (NextIndex>StoreSize) StoreSize=NextIndex;
if (NextIndex>realtime_access_log_lines) NextIndex=0;
}
- fclose(fp);
+ if (FileObject_Close(fp)) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),file_name,FileObject_GetLastCloseError());
+ exit(EXIT_FAILURE);
+ }
longline_destroy(&line);
datashow(StoredLogEntries,StoreIndex,StoreSize);