]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Strip suffix length is a global variable
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Jul 2015 07:34:42 +0000 (09:34 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Jul 2015 07:34:42 +0000 (09:34 +0200)
Compute only once the suffix length to strip from the user name and store
it globally.

getconf.c
readlog.c
redirector.c

index 99a8e1c75140e043a822bf9ff90b807ef82c3cfb..ee8bd0ecb0a020bcc5580e2db4185250e95bc9ea 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -45,6 +45,7 @@ extern char ImageDir[MAXLEN];
 extern FileListObject UserAgentLog;
 extern bool UserAgentFromCmdLine;
 extern char StripUserSuffix[MAX_USER_LEN];
+extern int StripSuffixLen;
 
 struct param_list
 {
@@ -913,7 +914,10 @@ static void parmtest(char *buf,const char *File)
 
        if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return;
 
-       if (getparam_string("strip_user_suffix",buf,StripUserSuffix,sizeof(StripUserSuffix))>0) return;
+       if (getparam_string("strip_user_suffix",buf,StripUserSuffix,sizeof(StripUserSuffix))>0) {
+               StripSuffixLen=strlen(StripUserSuffix);
+               return;
+       }
 
        if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
 
index d08306f330ce5f58fc036cdcaa51718f5083643a..34253b391b377140bb5ca6fd8a134da0a1c01024 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -91,6 +91,8 @@ numlist weekdays = { { 0, 1, 2, 3, 4, 5, 6 }, 7 };
 numlist hours = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, 24 };
 //! Domain suffix to strip from the user name.
 char StripUserSuffix[MAX_USER_LEN]="";
+//! Length of the suffix to strip from the user name.
+int StripSuffixLen=0;
 
 extern char *userfile;
 extern FileListObject AccessLog;
@@ -318,7 +320,6 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
        int x;
        int hmr;
        int nopen;
-       int StripSuffixLen;
        int maxopenfiles=MAX_OPEN_USER_FILES;
        unsigned long int recs1=0UL;
        unsigned long int recs2=0UL;
@@ -369,7 +370,6 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
 
        recs1=0UL;
        recs2=0UL;
-       StripSuffixLen=strlen(StripUserSuffix);
 
        // pre-read the file only if we have to show stats
        if (ShowReadStatistics && ShowReadPercent && fp_in->Rewind) {
index e7b89e0ab3ebea9d188da458d1699600b1ff8ee1..abd1fae5640f5d3ae11a7aea3cb84ba19ad65607 100644 (file)
@@ -34,10 +34,9 @@ static int nfiles_done = 0;
 static int RedirectorErrors=0;
 //! The file containing the sorted entries.
 static char redirector_sorted[MAXLEN]="";
-//! Length of the suffix to strip from the user name.
-static int StripSuffixLen;
 
 extern char StripUserSuffix[MAX_USER_LEN];
+extern int StripSuffixLen;
 
 static void parse_log(FILE *fp_ou,char *buf,int dfrom,int duntil)
 {
@@ -283,7 +282,6 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
                debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wentp);
                exit(EXIT_FAILURE);
        }
-       StripSuffixLen=strlen(StripUserSuffix);
 
        while ((buf=longline_read(fp_in,line)) != NULL) {
                parse_log(fp_ou,buf,dfrom,duntil);