]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - readlog_extlog.c
Indent the configure script for more readability.
[thirdparty/sarg.git] / readlog_extlog.c
index 91c86289832b20a007326404cf67fbcde06d6e4a..dd1542a83c00b31546fe4ada6d40c9ecc09d08c3 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"
 
 /*!
 Maximum number of columns accepted in an extended log format.
@@ -100,7 +101,7 @@ static bool ExtLog_Fields(const char *columns)
        col=0;
        while (*columns) {
                if (col>=MAX_EXT_COLUMNS) {
-                       debuga(_("Too many columns found in an extended log format. The maximum allowed is %d but it can be changed if a bigger value is legitimate\n"),MAX_EXT_COLUMNS);
+                       debuga(__FILE__,__LINE__,_("Too many columns found in an extended log format. The maximum allowed is %d but it can be changed if a bigger value is legitimate\n"),MAX_EXT_COLUMNS);
                        exit(EXIT_FAILURE);
                }
                prefix=-1;
@@ -118,10 +119,12 @@ static bool ExtLog_Fields(const char *columns)
                                }
                        }
                }
+               (void)prefix;//compiler pacifier
                if (i<0) len=0;
                for ( ; (unsigned char)columns[len]>' ' ; len++) {//skip a word and accept any separator (tab or space)
                        if (header_start>=0 && columns[len]==')') header_end=len;
                }
+               (void)header_end;//compiler pacifier
                col_sep=columns[len];
                ExtColSep[col]=col_sep;
 
@@ -152,7 +155,7 @@ static bool ExtLog_Fields(const char *columns)
                columns+=len;
                while (*columns && (unsigned char)*columns<=' ') {
                        if (*columns!=col_sep) {
-                               debuga(_("Multiple column separators found between two columns in the \"fields\" directive of an extended log format\n"));
+                               debuga(__FILE__,__LINE__,_("Multiple column separators found between two columns in the \"fields\" directive of an extended log format\n"));
                                exit(EXIT_FAILURE);
                        }
                        columns++;
@@ -262,7 +265,7 @@ static char *ExtLog_GetDate(char *Line,struct tm *Date)
                ++Line;
        }
        Date->tm_year=year-1900;
-       Date->tm_mon=month;
+       Date->tm_mon=month-1;
        Date->tm_mday=day;
        return(Line);
 }
@@ -380,7 +383,9 @@ static enum ReadLogReturnCodeEnum ExtLog_ReadEntry(char *Line,struct ReadLogStru
 {
        int col;
        enum ext_col_id col_id;
+       char *Ip=NULL;
        char *IpEnd;
+       char *User=NULL;
        char *UserEnd;
        char *UrlEnd;
        char *HttpCodeEnd;
@@ -396,19 +401,19 @@ static enum ReadLogReturnCodeEnum ExtLog_ReadEntry(char *Line,struct ReadLogStru
        col=0;
        while (*Line) {
                if (col>=ExtColNumber) {
-                       debuga(_("Too many columns in an extended log file format: %d columns found when %d have been announced\n"),col,ExtColNumber);
+                       debuga(__FILE__,__LINE__,_("Too many columns in an extended log file format: %d columns found when %d have been announced\n"),col,ExtColNumber);
                        return(RLRC_Unknown);
                }
                col_id=ExtLog_WhichColumn(col);
                switch (col_id)
                {
                        case EXTCOL_Ip:
-                               Entry->Ip=Line;
+                               Entry->Ip=Ip=Line;
                                Line=ExtLog_GetString(Line,col,&IpEnd);
                                if (!Line) return(RLRC_Unknown);
                                break;
                        case EXTCOL_UserName:
-                               Entry->User=Line;
+                               Entry->User=User=Line;
                                Line=ExtLog_GetString(Line,col,&UserEnd);
                                if (!Line) return(RLRC_Unknown);
                                break;
@@ -448,18 +453,18 @@ static enum ReadLogReturnCodeEnum ExtLog_ReadEntry(char *Line,struct ReadLogStru
                col++;
        }
        if (col!=ExtColNumber) {
-               debuga(_("Only %d columns in an extended log file format when %d have been announced\n"),col,ExtColNumber);
+               debuga(__FILE__,__LINE__,_("Only %d columns in an extended log file format when %d have been announced\n"),col,ExtColNumber);
                return(RLRC_Unknown);
        }
 
        // check the entry time
        if (mktime(&Entry->EntryTime)==-1) {
-               debuga(_("Invalid date or time found in the extended log file\n"));
+               debuga(__FILE__,__LINE__,_("Invalid date or time found in the extended log file\n"));
                return(RLRC_InternalError);
        }
 
-       ExtLog_FixString(Entry->Ip,IpEnd);
-       ExtLog_FixString(Entry->User,UserEnd);
+       ExtLog_FixString(Ip,IpEnd);
+       ExtLog_FixString(User,UserEnd);
        ExtLog_FixString(Entry->Url,UrlEnd);
        ExtLog_FixString(Entry->HttpCode,HttpCodeEnd);