From: Frederic Marchal Date: Fri, 21 Aug 2015 17:59:26 +0000 (+0200) Subject: Limit the useragent log period to the same period as the access log X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02d231f3f40a9a94d172771d2ee927a9a399d991;p=thirdparty%2Fsarg.git Limit the useragent log period to the same period as the access log If no explicit date range was provided on the command line, the useragent report used to contain the content of the whole useragent.log file even if it covered a wider period than the access log. Now, the useragent report only covers the same period as the access log provided they both overlap. If both logs cover distinct periods, the useragent log is not produced. --- diff --git a/documentation/util.txt b/documentation/util.txt index 755b356..8744126 100644 --- a/documentation/util.txt +++ b/documentation/util.txt @@ -406,18 +406,6 @@ Initialize the period with the content of the first line of a sarg log. -/*! \fn void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil) -Fill the period with the specified range. - -\param period The period to change. -\param dfrom The start date in the form year*10000+month*100+day. -\param duntil The end date in the form year*10000+month*100+day. -*/ - - - - - /*! \fn int getperiod_buildtext(struct periodstruct *period) Build the text to display as the date range of the report. diff --git a/include/defs.h b/include/defs.h index a6e3c24..26a1c4c 100644 --- a/include/defs.h +++ b/include/defs.h @@ -428,6 +428,7 @@ bool IsTreeDayFileName(const char *Name); int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us); int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period); void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil); +void getperiod_torange(const 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); diff --git a/redirector.c b/redirector.c index 5b1b896..23e8508 100644 --- a/redirector.c +++ b/redirector.c @@ -312,8 +312,7 @@ void redirector_log(void) exit(EXIT_FAILURE); } - dfrom=(period.start.tm_year+1900)*10000+(period.start.tm_mon+1)*100+period.start.tm_mday; - duntil=(period.end.tm_year+1900)*10000+(period.end.tm_mon+1)*100+period.end.tm_mday; + getperiod_torange(&period,&dfrom,&duntil); if (NRedirectorLogs>0) { for (i=0 ; istart,0,sizeof(period->start)); @@ -1053,6 +1060,21 @@ void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil) period->end.tm_year=(duntil/10000)-1900; } +/*! +Get the range from a period. + +\param period The period to convert to a range. +\param dfrom The variable to store the range beginning. It can be NULL. +\param duntil The variable to store the range end. It can be NULL. +*/ +void getperiod_torange(const struct periodstruct *period,int *dfrom,int *duntil) +{ + if (dfrom) + *dfrom=(period->start.tm_year+1900)*10000+(period->start.tm_mon+1)*100+period->start.tm_mday; + if (duntil) + *duntil=(period->end.tm_year+1900)*10000+(period->end.tm_mon+1)*100+period->end.tm_mday; +} + /*! Update the \a main period to encompass the period in \a candidate. */