From 9427469aa0c37adb92d025297122a304eed94b8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Sun, 26 Aug 2012 16:50:36 +0200 Subject: [PATCH] Ignore the sarg log file name until the format is confirmed 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/readlog_sarg.c b/readlog_sarg.c index 106f4c3..8f9a978 100644 --- a/readlog_sarg.c +++ b/readlog_sarg.c @@ -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); } -- 2.47.3