]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Ignore the sarg log file name until the format is confirmed
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Aug 2012 14:50:36 +0000 (16:50 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Aug 2012 14:50:36 +0000 (16:50 +0200)
The validity of the sarg input log file must be delayed until the format
header is detected or the filter will fail when parsing any other log
format.

readlog_sarg.c

index 106f4c3be66d83efa8390016e59787da2bfe3029..8f9a978f0a4eb9287ab715ee629e68d247008cba 100644 (file)
@@ -29,6 +29,8 @@
 
 //! \c True if the current log is known to be a sarg parsed log.
 static bool InSargLog=false;
+//! \c True if the file name is invalid.
+static bool InvalidFileName=true;
 
 /*!
 A new file is being read. The name of the file is \a FileName.
@@ -36,10 +38,7 @@ A new file is being read. The name of the file is \a FileName.
 static void Sarg_NewFile(const char *FileName)
 {
        InSargLog=false;
-       if (getperiod_fromsarglog(FileName,&period)<0) {
-               debuga(_("The name of the file is invalid: %s\n"),FileName);
-               exit(EXIT_FAILURE);
-       }
+       InvalidFileName=(getperiod_fromsarglog(FileName,&period)<0);
 }
 
 /*!
@@ -67,6 +66,10 @@ static enum ReadLogReturnCodeEnum Sarg_ReadEntry(char *Line,struct ReadLogStruct
        int Second;
 
        if (strncmp(Line,"*** SARG Log ***",16)==0) {
+               if (InvalidFileName) {
+                       debuga(_("The name of the file is invalid for a sarg log\n"));
+                       exit(EXIT_FAILURE);
+               }
                InSargLog=true;
                return(RLRC_Ignore);
        }