int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form);
int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period);
void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
+void getperiod_merge(struct periodstruct *main,struct periodstruct *candidate);
int getperiod_buildtext(struct periodstruct *period);
void removetmp(const char *outdir);
void zdate(char *ftime,int ftimesize, char DateFormat);
static bool InSargLog=false;
//! \c True if the file name is invalid.
static bool InvalidFileName=true;
+//! The last period extracted from the log file name.
+static struct periodstruct SargPeriod;
/*!
A new file is being read. The name of the file is \a FileName.
static void Sarg_NewFile(const char *FileName)
{
InSargLog=false;
- InvalidFileName=(getperiod_fromsarglog(FileName,&period)<0);
+ InvalidFileName=(getperiod_fromsarglog(FileName,&SargPeriod)<0);
}
/*!
debuga(_("The name of the file is invalid for a sarg log\n"));
exit(EXIT_FAILURE);
}
+ getperiod_merge(&period,&SargPeriod);
InSargLog=true;
return(RLRC_Ignore);
}
period->end.tm_year=(duntil/10000)-1900;
}
+/*!
+Update the \a main period to encompass the period in \a candidate.
+*/
+void getperiod_merge(struct periodstruct *main,struct periodstruct *candidate)
+{
+ int cdate;
+ int mdate;
+
+ mdate=(main->start.tm_year)*10000+(main->start.tm_mon)*100+main->start.tm_mday;
+ cdate=(candidate->start.tm_year)*10000+(candidate->start.tm_mon)*100+candidate->start.tm_mday;
+ if (cdate<mdate) memcpy(&main->start,&candidate->start,sizeof(struct tm));
+
+ mdate=(main->end.tm_year)*10000+(main->end.tm_mon)*100+main->end.tm_mday;
+ cdate=(candidate->end.tm_year)*10000+(candidate->end.tm_mon)*100+candidate->end.tm_mday;
+ if (cdate>mdate) memcpy(&main->end,&candidate->end,sizeof(struct tm));
+}
+
int getperiod_buildtext(struct periodstruct *period)
{
int i;