]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Limit the useragent log period to the same period as the access log
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 21 Aug 2015 17:59:26 +0000 (19:59 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 21 Aug 2015 17:59:26 +0000 (19:59 +0200)
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.

documentation/util.txt
include/defs.h
redirector.c
useragent.c
util.c

index 755b356620a2f98d89244a2c9f760ecd168be67f..8744126d4437ee69b33780643295815edda55738 100644 (file)
@@ -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.
 
index a6e3c24c89c75a491961aa510bc87a13d10302ac..26a1c4cb6f0c331ba9601aa0548dc84862f0bc59 100644 (file)
@@ -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);
index 5b1b896ab266339c179d0764df3ff60da98a36e7..23e8508b79e49b64a80bc360598b477cdce31ce6 100644 (file)
@@ -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 ; i<NRedirectorLogs ; i++)
index 73ff3991febffbe2b47d321a2044615067c9e870..53c5f4d275db335ffa81cbb9540d1ec8594f923f 100644 (file)
@@ -94,6 +94,8 @@ void UserAgent_Readlog(void)
        longline line;
        FileListIterator FIter;
        struct tm logtime;
+       int dfrom;
+       int duntil;
 
        fp_ou=UserAgent_Open();
 
@@ -102,6 +104,7 @@ void UserAgent_Readlog(void)
                exit(EXIT_FAILURE);
        }
        memset(&logtime,0,sizeof(logtime));
+       getperiod_torange(&period,&dfrom,&duntil);
 
        FIter=FileListIter_Open(UserAgentLog);
        while ((FileName=FileListIter_Next(FIter))!=NULL)
diff --git a/util.c b/util.c
index dc75be0ffb9aabccfc6d6be81aaf7c2dd40ef4cc..0a48ffe3dde6d556b978e808ca1c6dcfbbee4605 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1040,6 +1040,13 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
        return(-1);
 }
 
+/*!
+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.
+*/
 void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil)
 {
        memset(&period->start,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.
 */