From: Frederic Marchal Date: Sun, 26 Jul 2015 07:34:42 +0000 (+0200) Subject: Strip suffix length is a global variable X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c0584166ffce932276910a4e1ad058f7948f879;p=thirdparty%2Fsarg.git Strip suffix length is a global variable Compute only once the suffix length to strip from the user name and store it globally. --- diff --git a/getconf.c b/getconf.c index 99a8e1c..ee8bd0e 100644 --- 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; diff --git a/readlog.c b/readlog.c index d08306f..34253b3 100644 --- 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) { diff --git a/redirector.c b/redirector.c index e7b89e0..abd1fae 100644 --- a/redirector.c +++ b/redirector.c @@ -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);