From: Frédéric Marchal Date: Sun, 26 Aug 2012 14:50:36 +0000 (+0200) Subject: Ignore the sarg log file name until the format is confirmed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9427469aa0c37adb92d025297122a304eed94b8b;p=thirdparty%2Fsarg.git 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. --- 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); }