]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fixed bug #1740268.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 1 Aug 2009 20:24:19 +0000 (20:24 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 1 Aug 2009 20:24:19 +0000 (20:24 +0000)
include/info.h
log.c
report.c

index 6c412b4fdd364f8f438c035775ec1db80b177286..4d7e332fb2a4736caa6bc01703486d20215a8382 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Jul-20-2009"
+#define VERSION PACKAGE_VERSION" Aug-01-2009"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/log.c b/log.c
index 52b5da9552f16ca53ccdb6fdb85df83826495f50..2f0bc6217ad9b845daa014fe0a0836abd7eaf98b 100644 (file)
--- a/log.c
+++ b/log.c
@@ -107,7 +107,7 @@ int main(int argc,char *argv[])
    int  narq=0;
    int  iarq=0;
    int  exstring=0;
-   int  i0=0,i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0;
+   int  i0=0,i1=-1,i2=-1,i3=-1,i4=-1,i5=-1,i6=-1,i7=-1,i8=-1;
    long totregsl=0;
    long totregsg=0;
    long totregsx=0;
@@ -925,12 +925,12 @@ int main(int argc,char *argv[])
                   printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
                   exit(1);
                }
-               while(strstr(bufz,"\t") != 0) {
-                  if (getword(val1,sizeof(val1),bufz,'\t')<0){
+               fixendofline(bufz);
+               while(bufz[0] != '\0') {
+                     if (getword(val1,sizeof(val1),bufz,'\t')<0){
                      printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
                      exit(1);
                   }
-                  i0++;
                   if(strcmp(val1,"c-ip") == 0) i1=i0;
                   if(strcmp(val1,"cs-username") == 0) i2=i0;
                   if(strcmp(val1,"date") == 0) i3=i0;
@@ -939,63 +939,67 @@ int main(int argc,char *argv[])
                   if(strcmp(val1,"sc-bytes") == 0) i6=i0;
                   if(strcmp(val1,"cs-uri") == 0) i7=i0;
                   if(strcmp(val1,"sc-status") == 0) i8=i0;
+                  i0++;
                }
-            }
-            fgets(bufz,sizeof(bufz),fp_in);
-            strcpy(val1,bufz);
-            for(x=0; x<=i1-1; x++) {
-               if (getword3(ip,sizeof(ip),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
-               }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i2-1; x++) {
-               if (getword3(user,sizeof(user),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
-               }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i3-1; x++) {
-               if (getword3(data,sizeof(data),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
-               }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i4-1; x++) {
-               if (getword3(hora,sizeof(hora),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
-               }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i5-1; x++) {
-               if (getword3(elap,sizeof(elap),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
+               if (i1<0) {
+                  // not the line we are looking for
+                  i0=0;
                }
             }
-            strcpy(val1,bufz);
-            for(x=0; x<=i6-1; x++) {
-               if (getword3(tam,sizeof(tam),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
-               }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i7-1; x++) {
-               if (getword3(url,sizeof(url),val1,'\t')<0) {
+            fgets(bufz,sizeof(bufz),fp_in);
+            for (x=0 ; x<i0 ; x++) {
+               if (getword3(val1,sizeof(val1),bufz,'\t')<0) {
                   printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
                   exit(1);
                }
-            }
-            strcpy(val1,bufz);
-            for(x=0; x<=i8-1; x++) {
-               if (getword3(code,sizeof(code),val1,'\t')<0) {
-                  printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-                  exit(1);
+               if (x==i1) {
+                  if (strlen(val1)>=sizeof(ip)) {
+                     printf("SARG: Maybe you have a broken IP in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(ip,val1);
+               } else if (x==i2) {
+                  if (strlen(val1)>=sizeof(user)) {
+                     printf("SARG: Maybe you have a broken user in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(user,val1);
+               } else if (x==i3) {
+                  if (strlen(val1)>=sizeof(data)) {
+                     printf("SARG: Maybe you have a broken date in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(data,val1);
+               } else if (x==i4) {
+                  if (strlen(val1)>=sizeof(hora)) {
+                     printf("SARG: Maybe you have a broken time in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(hora,val1);
+               } else if (x==i5) {
+                  if (strlen(val1)>=sizeof(elap)) {
+                     printf("SARG: Maybe you have a broken download duration in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(elap,val1);
+               } else if (x==i6) {
+                  if (strlen(val1)>=sizeof(tam)) {
+                     printf("SARG: Maybe you have a broken download size in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(tam,val1);
+               } else if (x==i7) {
+                  if (strlen(val1)>=sizeof(url)) {
+                     printf("SARG: Maybe you have a broken URL in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(url,val1);
+               } else if (x==i8) {
+                  if (strlen(val1)>=sizeof(code)) {
+                     printf("SARG: Maybe you have a broken access code in your %s file.\n",arq);
+                     exit(1);
+                  }
+                  strcpy(code,val1);
                }
             }
 
@@ -1017,6 +1021,7 @@ int main(int argc,char *argv[])
          }
 
          if(strlen(user) > 150) {
+            if (debugm) printf("User too long: %s\n",user);
             totregsx++;
             continue;
          }
@@ -1029,6 +1034,7 @@ int main(int argc,char *argv[])
          }
 
          if(vercode(code)) {
+            if (debugm) printf("Excluded code: %s\n",code);
             totregsx++;
             continue;
          }
@@ -1096,6 +1102,7 @@ int main(int argc,char *argv[])
                exit(1);
             }
             if (!strchr(url,'/')) {
+               if (debugm) printf("URL without directory: %s\n",url);
                totregsx++;
                continue;
             }
@@ -1197,8 +1204,10 @@ int main(int argc,char *argv[])
             if(fhost) {
 //              l=vhexclude(excludefile,ip);
                l=vhexclude(excludefile,url);
-               if(!l)
+               if(!l) {
+                  if (debugm) printf("Excluded site: %s\n",url);
                   totregsx++;
+               }
             }
          }
 
@@ -1260,8 +1269,10 @@ int main(int argc,char *argv[])
          if(l) {
             if(fuser) {
                l=vuexclude(excludeuser,user);
-               if(!l)
+               if(!l) {
+                  if (debugm) printf("Excluded user: %s\n",user);
                   totregsx++;
+               }
             }
          }
 
index 8b720f649d11e2df46769bc277995a772e7e132b..eefc6149e95b62318fc34b93f33cb121268de96e 100644 (file)
--- a/report.c
+++ b/report.c
 static void maketmp(const char *user, const char *dirname, int debug, int indexonly);
 static void maketmp_hour(const char *user, const char *dirname, int indexonly);
 static void gravatmp_hora(const char *dirname, const char *user, const char *data, const char *hora, const char *elap, const char *accbytes, int indexonly);
-static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
-static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
-static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache);
-static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
+static void gravatmpf(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
+static void gravaporuser(const char *user, const char *dirname, const char *url, const char *ip, const char *data, const char *hora, const char *tam, const char *elap, int indexonly);
+static void gravager(char *dirname, const char *user, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache);
+static void grava_SmartFilter(const char *dirname, const char *user, const char *ip, const char *data, const char *hora, const char *url, const char *smart);
 
 void gerarel(void)
 {
@@ -500,7 +500,7 @@ static void gravatmp_hora(const char *dirname, const char *user, const char *dat
 }
 
 
-static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly)
+static void gravaporuser(const char *user, const char *dirname, const char *url, const char *ip, const char *data, const char *hora, const char *tam, const char *elap, int indexonly)
 {
 
    FILE *fp_ou;
@@ -528,7 +528,7 @@ static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *d
 }
 
 
-static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
+static void gravatmpf(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
 {
 
    FILE *fp_ou;
@@ -560,7 +560,7 @@ static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long i
 
    if(fp_tt) {
       fputs("</table>\n",fp_tt);
-      fputs("</html>\n",fp_tt);
+      fputs("</body>\n</html>\n",fp_tt);
       fclose(fp_tt);
    }
 
@@ -569,7 +569,7 @@ static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long i
 }
 
 
-static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache)
+static void gravager(char *dirname, const char *user, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache)
 {
 
    FILE *fp_ou;
@@ -594,7 +594,7 @@ static void gravager(char *dirname, char *user, long long int nacc, char *url, l
 
 }
 
-static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart)
+static void grava_SmartFilter(const char *dirname, const char *user, const char *ip, const char *data, const char *hora, const char *url, const char *smart)
 {
 
    FILE *fp_ou;