]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - readlog_common.c
Generate redirector log even if -d is not given
[thirdparty/sarg.git] / readlog_common.c
index 39753da8f4ea529e71171f0247dde3d9fcb0f54e..b39ee9b9a313c5f8164f25144cd31e8f3223d98f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2012
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -26,6 +26,7 @@
 
 #include "include/conf.h"
 #include "include/defs.h"
+#include "include/readlog.h"
 
 /*!
 A new file is being read. The name of the file is \a FileName.
@@ -78,9 +79,11 @@ static enum ReadLogReturnCodeEnum Common_ReadEntry(char *Line,struct ReadLogStru
        int Hour;
        int Minute;
        int Second;
+       char *Ip;
+       char *User;
 
        // get IP address
-       Entry->Ip=Line;
+       Entry->Ip=Ip=Line;
        for (IpLen=0 ; *Line && *Line!=' ' ; IpLen++) Line++;
        if (*Line!=' ' || IpLen==0) return(RLRC_Unknown);
 
@@ -92,7 +95,7 @@ static enum ReadLogReturnCodeEnum Common_ReadEntry(char *Line,struct ReadLogStru
        }
 
        // the ID of the user or - if the user is unidentified
-       Entry->User=++Line;
+       Entry->User=User=++Line;
        for (UserLen=0 ; *Line && *Line!=' ' ; UserLen++) Line++;
        if (*Line!=' ' || UserLen==0) return(RLRC_Unknown);
 
@@ -185,15 +188,15 @@ static enum ReadLogReturnCodeEnum Common_ReadEntry(char *Line,struct ReadLogStru
 
        // check the entry time
        if (mktime(&Entry->EntryTime)==-1) {
-               debuga(_("Invalid date or time found in the common log file\n"));
+               debuga(__FILE__,__LINE__,_("Invalid date or time found in the common log file\n"));
                return(RLRC_InternalError);
        }
 
        // it is safe to alter the line buffer now that we are returning a valid entry
-       Entry->Ip[IpLen]='\0';
+       Ip[IpLen]='\0';
        Entry->HttpCode[HttpCodeLen]='\0';
        Entry->Url[UrlLen]='\0';
-       Entry->User[UserLen]='\0';
+       User[UserLen]='\0';
 
        return(RLRC_NoError);
 }