]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - util.c
Limit the useragent log period to the same period as the access log
[thirdparty/sarg.git] / util.c
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.
 */