]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Parse some of the configuration flags in getconf.c once and use bits mask during...
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 27 Jan 2010 19:03:52 +0000 (19:03 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 27 Jan 2010 19:03:52 +0000 (19:03 +0000)
ChangeLog
datafile.c
getconf.c
html.c
include/conf.h
log.c
report.c
sort.c
topsites.c
topuser.c
totday.c

index 4cb249fc32ab466043a569bad997897bf4c39389..522bfc585c2d1b8f45f7e6378fb6a232700c0c56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,11 @@
 SARG ChangeLog
 
-Dec-12-2009 Version 2.3
+Jan-27-2009 Version 2.3
                - LDAP usertab added. 
                  Now you can have your users in a LDAP Server.
                  Use these tags in sarg.conf: LDAPHost, LDAPPort, LDAPBindDN, LDAPBindPW,
                                               LDAPBaseSearch, LDAPFilterSearch
+               - Parse the string flags from sarg.conf once during the reading of sarg.conf instead of manipulating and duplicating the tests of the strings where they are used.
 
 Jan-22-2010 Version 2.2.7
                - Extra compile and run time protection (FORTIFY_SOURCE) fixed in configure.
index 7c941083ac1b2e9280a1dfe7319ef4687a235361..c69066fa40d91078ac805cb096ab70e670e21b60 100644 (file)
@@ -166,41 +166,41 @@ void saverecs(char *dirname, char *user, long long int nacc, char *url, long lon
    my_lltoa(incache,val4,0);
    my_lltoa(oucache,val5,0);
 
-   if(strstr(DataFileFields,"user") != 0) {
+   if((DataFileFields & DATA_FIELD_USER) != 0) {
       strcpy(reg,user);
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"date") != 0) {
+   if((DataFileFields & DATA_FIELD_DATE) != 0) {
       strncat(reg,dia,strlen(dia));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"time") != 0) {
+   if((DataFileFields & DATA_FIELD_TIME) != 0) {
       strncat(reg,hora,strlen(hora));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"url") != 0) {
+   if((DataFileFields & DATA_FIELD_URL) != 0) {
       strcpy(name,url);
       if (strcmp(DataFileUrl,"ip") == 0) name2ip(name);
       strncat(reg,name,strlen(name));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"connect") != 0) {
+   if((DataFileFields & DATA_FIELD_CONNECT) != 0) {
       strncat(reg,val1,strlen(val1));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"bytes") != 0) {
+   if((DataFileFields & DATA_FIELD_BYTES) != 0) {
       strncat(reg,val2,strlen(val2));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"in_cache") != 0) {
+   if((DataFileFields & DATA_FIELD_IN_CACHE) != 0) {
       strncat(reg,val4,strlen(val4));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"out_cache") != 0) {
+   if((DataFileFields & DATA_FIELD_OUT_CACHE) != 0) {
       strncat(reg,val5,strlen(val5));
       strncat(reg,DataFileDelimiter,1);
    }
-   if(strstr(DataFileFields,"elapsed") != 0) {
+   if((DataFileFields & DATA_FIELD_ELAPSED) != 0) {
       strncat(reg,val3,strlen(val3));
       strncat(reg,DataFileDelimiter,1);
    }
index 32e38f41ee6bfc9f96aa8567f5146927d6412431..456c249da56f493a436ccb0897f85297c45d1100 100644 (file)
--- a/getconf.c
+++ b/getconf.c
 #include "include/conf.h"
 #include "include/defs.h"
 
+#define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
+
 extern numlist hours, weekdays;
 
+struct param_list
+{
+   //! The name of the value of the parameter.
+   const char *name;
+   //! The bit to set if the value is found.
+   unsigned long int value;
+   //! The value is invalid if any bit of this mask is set in the parameter.
+   unsigned long int exclude;
+};
+
+struct param_list report_type_values[]=
+{
+   {"users_sites",REPORT_TYPE_USERS_SITES,0},
+   {"topusers",REPORT_TYPE_TOPUSERS,0},
+   {"topsites",REPORT_TYPE_TOPSITES,0},
+   {"sites_users",REPORT_TYPE_SITES_USERS,0},
+   {"date_time",REPORT_TYPE_DATE_TIME,0},
+   {"denied",REPORT_TYPE_DENIED,0},
+   {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
+   {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
+   {"downloads",REPORT_TYPE_DOWNLOADS,0},
+};
+
+struct param_list data_field_values[]=
+{
+   {"user",DATA_FIELD_USER,0},
+   {"date",DATA_FIELD_DATE,0},
+   {"time",DATA_FIELD_TIME,0},
+   {"url",DATA_FIELD_URL,0},
+   {"connect",DATA_FIELD_CONNECT,0},
+   {"bytes",DATA_FIELD_BYTES,0},
+   {"in_cache",DATA_FIELD_IN_CACHE,0},
+   {"out_cache",DATA_FIELD_OUT_CACHE,0},
+   {"elapsed",DATA_FIELD_ELAPSED,0},
+};
+
+struct param_list topuserfields_values[]=
+{
+   {"NUM",TOPUSERFIELDS_NUM,0},
+   {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
+   {"USERID",TOPUSERFIELDS_USERID,0},
+   {"CONNECT",TOPUSERFIELDS_CONNECT,0},
+   {"BYTES",TOPUSERFIELDS_BYTES,0},
+   {"%BYTES",TOPUSERFIELDS_SETYB,0},
+   {"SETYB",TOPUSERFIELDS_SETYB,0},
+   {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
+   {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
+   {"MILISEC",TOPUSERFIELDS_MILISEC,0},
+   {"%TIME",TOPUSERFIELDS_PTIME,0},
+   {"TOTAL",TOPUSERFIELDS_TOTAL,0},
+   {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
+};
+
+struct param_list userreportfields_values[]=
+{
+   {"CONNECT",USERREPORTFIELDS_CONNECT,0},
+   {"BYTES",USERREPORTFIELDS_BYTES,0},
+   {"%BYTES",USERREPORTFIELDS_SETYB,0},
+   {"SETYB",USERREPORTFIELDS_SETYB,0},
+   {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0},
+   {"USED_TIME",USERREPORTFIELDS_USED_TIME,0},
+   {"MILISEC",USERREPORTFIELDS_MILISEC,0},
+   {"%TIME",USERREPORTFIELDS_PTIME,0},
+   {"TOTAL",USERREPORTFIELDS_TOTAL,0},
+   {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
+};
+
 static int is_param(const char *param,const char *buf)
 {
    int plen;
@@ -172,6 +241,41 @@ static int getparam_bool(const char *param,char *buf,int *value)
    return(1);
 }
 
+static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
+{
+   int plen;
+   char *str;
+   int i;
+
+   plen=strlen(param);
+   if (strncmp(buf,param,plen) != 0) return(0);
+   buf+=plen;
+   if ((unsigned char)*buf>' ') return(0);
+   while (*buf && (unsigned char)*buf<=' ') buf++;
+
+   *value=0UL;
+   while (*buf) {
+      str=buf;
+      while (*str && (unsigned char)*str>' ' && *str!=';') str++;
+      if (*str) {
+         *str++='\0';
+         while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
+      }
+      for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
+      if (i>=noptions) {
+         fprintf(stderr,"SARG: Unknown value %s for parameter %s\n",buf,param);
+         exit(1);
+      }
+      if ((*value & options[i].exclude)!=0) {
+         fprintf(stderr,"SARG: Value %s conflicts with other selected values of parameter %s\n",buf,param);
+         exit(1);
+      }
+      *value|=options[i].value;
+      buf=str;
+   }
+   return(1);
+}
+
 static void parmtest(char *buf)
 {
    char wbuf[50];
@@ -280,7 +384,7 @@ static void parmtest(char *buf)
 
    if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
 
-   if (getparam_string("report_type",buf,ReportType,sizeof(ReportType))>0) return;
+   if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
 
    if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
 
@@ -354,17 +458,17 @@ static void parmtest(char *buf)
 
    if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
 
-   if (getparam_string("topuser_fields",buf,TopUserFields,sizeof(TopUserFields))>0) return;
+   if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
 
    if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
 
-   if (getparam_string("user_report_fields",buf,UserReportFields,sizeof(UserReportFields))>0) return;
+   if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
 
    if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
 
    if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
 
-   if (getparam_string("datafile_fields",buf,DataFileFields,sizeof(DataFileFields))>0) return;
+   if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
 
    if (getparam_string("datafile_url",buf,DataFileUrl,sizeof(DataFileUrl))>0) return;
 
diff --git a/html.c b/html.c
index 79f174d2afc01611063724b004081d8ed391cdd0..2e50ad7cd2ff2b693da06e36cedce9f34ad8b5f9 100644 (file)
--- a/html.c
+++ b/html.c
@@ -60,7 +60,7 @@ void htmlrel(void)
    char siteind[MAXLEN];
    struct getwordstruct gwarea;
 
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    strcpy(tmp2,TempDir);
    strcat(tmp2,"/sargtmp.unsort");
@@ -264,22 +264,22 @@ void htmlrel(void)
       strcpy(val9,"colspan=\"2\"");
       bzero(val10, 255);
 
-      if(strstr(UserReportFields,"CONNECT") == 0)
+      if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0)
          bzero(val3, 255);
-      if(strstr(UserReportFields,"BYTES") == 0)
+      if((UserReportFields & USERREPORTFIELDS_BYTES) == 0)
          bzero(val4, 255);
-      if(strstr(UserReportFields,"SETYB") == 0)
+      if((UserReportFields & USERREPORTFIELDS_SETYB) == 0)
          bzero(val11, 255);
-      if(strstr(UserReportFields,"IN-CACHE-OUT") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
          bzero(val5, 255);
          bzero(val9, 255);
          strcpy(val10,"<td></td>");
       }
-      if(strstr(UserReportFields,"USED_TIME") == 0)
+      if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0)
          bzero(val6, 255);
-      if(strstr(UserReportFields,"MILISEC") == 0)
+      if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0)
          bzero(val7, 255);
-      if(strstr(UserReportFields,"%TIME") == 0)
+      if((UserReportFields & USERREPORTFIELDS_PTIME) == 0)
          bzero(val8, 255);
 
       fprintf(fp_ou,"<tr><th></th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header3\" %s>%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],val3,val4,val11,val9,val5,val6,val7,val8);
@@ -383,7 +383,7 @@ void htmlrel(void)
                snprintf(httplink,sizeof(httplink),"<a href=\"http://%s\" title=\"%s\">%s</a>",urly,urly,url);
          }
 
-         if(strstr(ReportType,"site_user_time_date") != 0) {
+         if((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
             strcpy(ltext110,text[110]);
             for(s=ltext110; *s; ++s)
                *s=tolower(*s);
@@ -407,33 +407,33 @@ void htmlrel(void)
          sprintf(val6,"%s",buildtime(nnelap));
          sprintf(val7,"%3.2f%%",perc2);
 
-         if(strstr(UserReportFields,"CONNECT") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
             bzero(wwork1, 255);
             bzero(hbc1, 30);
          }
-         if(strstr(UserReportFields,"BYTES") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
             bzero(wwork2, 255);
             bzero(hbc2, 30);
          }
-         if(strstr(UserReportFields,"MILISEC") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
             bzero(wwork3, 255);
             bzero(hbc3, 30);
          }
-         if(strstr(UserReportFields,"SETYB") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_SETYB) == 0) {
             bzero(val3, 255);
             bzero(hbc4, 30);
          }
-         if(strstr(UserReportFields,"IN-CACHE-OUT") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
             bzero(val4, 255);
             bzero(val5, 255);
             bzero(hbc5, 30);
             bzero(hbc6, 30);
          }
-         if(strstr(UserReportFields,"USED_TIME") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
             bzero(val6, 255);
             bzero(hbc7, 30);
          }
-         if(strstr(UserReportFields,"%TIME") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
             bzero(val7, 255);
             bzero(hbc8, 30);
          }
@@ -587,40 +587,38 @@ void htmlrel(void)
       strcpy(hbc8,"class=\"header2\"");
       strcpy(hbc9,"class=\"header\"");
 
-      if(strstr(UserReportFields,"CONNECT") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
          bzero(wwork1, 255);
          bzero(hbc1, 30);
       }
-      if(strstr(UserReportFields,"BYTES") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
          bzero(wwork2, 255);
          bzero(hbc2, 30);
       }
-      if(strstr(UserReportFields,"MILISEC") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
          bzero(wwork3, 255);
          bzero(hbc3, 30);
       }
-      if(strstr(UserReportFields,"SETYB") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_SETYB) == 0) {
          bzero(val3, 255);
          bzero(hbc4, 30);
       }
-      if(strstr(UserReportFields,"IN-CACHE-OUT") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
          bzero(val4, 255);
          bzero(hbc5, 30);
-      }
-      if(strstr(UserReportFields,"IN-CACHE-OUT") == 0) {
          bzero(val5, 255);
          bzero(hbc6, 30);
       }
-      if(strstr(UserReportFields,"USED_TIME") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
          bzero(val6, 255);
          bzero(hbc7, 30);
       }
-      if(strstr(UserReportFields,"%TIME") == 0) {
+      if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
          bzero(val7, 255);
          bzero(hbc8, 30);
       }
 
-      if(strstr(UserReportFields,"TOTAL") != 0) {
+      if((UserReportFields & USERREPORTFIELDS_TOTAL) != 0) {
          fprintf(fp_ou,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc9,text[107],hbc1,wwork1,hbc2,wwork2,hbc4,val3,hbc5,val4,hbc6,val5,hbc7,val6,hbc3,wwork3,hbc8,val7);
       }
 
@@ -664,7 +662,7 @@ void htmlrel(void)
 //     continue;
 //      }
 
-      if (strstr(ReportType,"topuser") != 0) {
+      if ((ReportType & REPORT_TYPE_TOPUSERS) != 0) {
          strcpy(arqper,dirname);
          strcat(arqper,"/sarg-users");
 
@@ -711,28 +709,28 @@ void htmlrel(void)
          strcpy(hbc5,"class=\"header2\"");
          strcpy(hbc6,"class=\"header\"");
 
-         if(strstr(UserReportFields,"CONNECT") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
             bzero(wwork1, 255);
             bzero(hbc1, 30);
          }
-         if(strstr(UserReportFields,"BYTES") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
             bzero(wwork2, 255);
             bzero(hbc2, 30);
          }
-         if(strstr(UserReportFields,"MILISEC") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
             bzero(wwork3, 255);
             bzero(hbc3, 30);
          }
-         if(strstr(UserReportFields,"USED_TIME") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
             bzero(val6, 255);
             bzero(hbc4, 30);
          }
-         if(strstr(UserReportFields,"%TIME") == 0) {
+         if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
             bzero(val7, 255);
             bzero(hbc5, 30);
          }
 
-         if(strstr(UserReportFields,"AVERAGE") != 0) {
+         if((UserReportFields & USERREPORTFIELDS_AVERAGE) != 0) {
             fprintf(fp_ou,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th></th><th></th><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc6,text[96],hbc1,wwork1,hbc2,wwork2,hbc4,val6,hbc3,wwork3,hbc5,val7);
          }
       } /* added */
index b58a70a25ea78c797ffb78a1860a38f41c7c6886..785801d3ebc167e89254a78a5803e637dbd8ef8d 100755 (executable)
@@ -137,6 +137,49 @@ int mkstemps(char *template, int suffixlen);
 #define MAXLEN 20000
 #define MAXLOGS 255
 
+#define REPORT_TYPE_USERS_SITES         0x0001UL
+#define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL
+#define REPORT_TYPE_TOPUSERS            0x0004UL
+#define REPORT_TYPE_TOPSITES            0x0008UL
+#define REPORT_TYPE_SITES_USERS         0x0010UL
+#define REPORT_TYPE_DATE_TIME           0x0020UL
+#define REPORT_TYPE_DENIED              0x0040UL
+#define REPORT_TYPE_AUTH_FAILURES       0x0080UL
+#define REPORT_TYPE_DOWNLOADS           0x0100UL
+
+#define DATA_FIELD_USER      0x0001UL
+#define DATA_FIELD_DATE      0x0002UL
+#define DATA_FIELD_TIME      0x0004UL
+#define DATA_FIELD_URL       0x0008UL
+#define DATA_FIELD_CONNECT   0x0010UL
+#define DATA_FIELD_BYTES     0x0020UL
+#define DATA_FIELD_IN_CACHE  0x0040UL
+#define DATA_FIELD_OUT_CACHE 0x0080UL
+#define DATA_FIELD_ELAPSED   0x0100UL
+
+#define TOPUSERFIELDS_NUM          0x0001UL
+#define TOPUSERFIELDS_DATE_TIME    0x0002UL
+#define TOPUSERFIELDS_USERID       0x0004UL
+#define TOPUSERFIELDS_CONNECT      0x0008UL
+#define TOPUSERFIELDS_BYTES        0x0010UL
+#define TOPUSERFIELDS_SETYB        0x0020UL
+#define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL
+#define TOPUSERFIELDS_USED_TIME    0x0080UL
+#define TOPUSERFIELDS_MILISEC      0x0100UL
+#define TOPUSERFIELDS_PTIME        0x0200UL
+#define TOPUSERFIELDS_TOTAL        0x0400UL
+#define TOPUSERFIELDS_AVERAGE      0x0800UL
+
+#define USERREPORTFIELDS_CONNECT      0x0001UL
+#define USERREPORTFIELDS_BYTES        0x0002UL
+#define USERREPORTFIELDS_SETYB        0x0004UL
+#define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL
+#define USERREPORTFIELDS_USED_TIME    0x0010UL
+#define USERREPORTFIELDS_MILISEC      0x0020UL
+#define USERREPORTFIELDS_PTIME        0x0040UL
+#define USERREPORTFIELDS_TOTAL        0x0080UL
+#define USERREPORTFIELDS_AVERAGE      0x0100UL
+
 FILE *fp_tt;
 
 char outdir[MAXLEN];
@@ -181,7 +224,7 @@ int TopUsersNum;
 char ExcludeCodes[256];
 char TopsitesSortField[15];
 char TopsitesSortType[20];
-char ReportType[255];
+unsigned long int ReportType;
 char UserTabFile[255];
 char warea[MAXLEN];
 char name[MAXLEN];
@@ -236,11 +279,11 @@ char PrivacyStringColor[30];
 char IncludeUsers[MAXLEN];
 char ExcludeString[MAXLEN];
 int SuccessfulMsg;
-char TopUserFields[255];
-char UserReportFields[255];
+unsigned long int TopUserFields;
+unsigned long int UserReportFields;
 char DataFile[MAXLEN];
 char DataFileDelimiter[3];
-char DataFileFields[MAXLEN];
+unsigned long int DataFileFields;
 char DataFileUrl[20];
 char SiteUserTimeDateType[10];
 int ShowReadStatistics;
diff --git a/log.c b/log.c
index 299bc9e182159b4bb11294b82209625ab3344475..8f4d76c1b3b9f1e5609c68c57bbc866ff427572e 100644 (file)
--- a/log.c
+++ b/log.c
@@ -142,7 +142,7 @@ int main(int argc,char *argv[])
    ConfigFile[0]='\0';
    code[0]='\0';
    LastLog=0;
-   ReportType[0]='\0';
+   ReportType=0UL;
    UserTabFile[0]='\0';
    BlockIt[0]='\0';
    ExternalCSSFile[0]='\0';
@@ -191,10 +191,16 @@ int main(int argc,char *argv[])
    strcpy(PrivacyString,"***.***.***.***");
    strcpy(PrivacyStringColor,"blue");
    SuccessfulMsg=1;
-   strcpy(TopUserFields,"NUM DATE_TIME USERID CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE");
-   strcpy(UserReportFields,"CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE");
+   TopUserFields=TOPUSERFIELDS_NUM | TOPUSERFIELDS_DATE_TIME | TOPUSERFIELDS_USERID | TOPUSERFIELDS_CONNECT |
+                 TOPUSERFIELDS_BYTES | TOPUSERFIELDS_SETYB | TOPUSERFIELDS_IN_CACHE_OUT |
+                 TOPUSERFIELDS_USED_TIME | TOPUSERFIELDS_MILISEC | TOPUSERFIELDS_PTIME |
+                 TOPUSERFIELDS_TOTAL | TOPUSERFIELDS_AVERAGE;
+   UserReportFields=USERREPORTFIELDS_CONNECT | USERREPORTFIELDS_BYTES | USERREPORTFIELDS_SETYB |
+                    USERREPORTFIELDS_IN_CACHE_OUT | USERREPORTFIELDS_USED_TIME | USERREPORTFIELDS_MILISEC |
+                    USERREPORTFIELDS_PTIME | USERREPORTFIELDS_TOTAL | USERREPORTFIELDS_AVERAGE;
    strcpy(DataFileDelimiter,";");
-   strcpy(DataFileFields,"user;date;time;url;connect;bytes;in_cache;out_cache;elapsed");
+   DataFileFields=DATA_FIELD_USER | DATA_FIELD_DATE | DATA_FIELD_TIME | DATA_FIELD_URL | DATA_FIELD_CONNECT |
+                  DATA_FIELD_BYTES | DATA_FIELD_IN_CACHE | DATA_FIELD_OUT_CACHE | DATA_FIELD_ELAPSED;
    strcpy(SiteUserTimeDateType,"table");
    ShowReadStatistics=1;
    strcpy(IndexSortOrder,"D");
@@ -463,10 +469,6 @@ int main(int argc,char *argv[])
    if(DataFile[0] != '\0')
       dataonly++;
 
-   subs(TopUserFields,sizeof(TopUserFields),"%BYTES","SETYB");
-
-   subs(UserReportFields,sizeof(UserReportFields),"%BYTES","SETYB");
-
    if(!NAccessLog) {
       strcpy(AccessLog[0],"/var/log/squid/access.log");
       NAccessLog++;
@@ -496,8 +498,11 @@ int main(int argc,char *argv[])
       fhost++;
    }
 
-   if(ReportType[0] == '\0')
-      strcpy(ReportType,"topusers topsites users_sites sites_users date_time denied auth_failures site_user_time_date downloads");
+   if(ReportType == 0) {
+      ReportType=REPORT_TYPE_TOPUSERS | REPORT_TYPE_TOPSITES | REPORT_TYPE_USERS_SITES |
+                 REPORT_TYPE_SITES_USERS | REPORT_TYPE_DATE_TIME | REPORT_TYPE_DENIED |
+                 REPORT_TYPE_AUTH_FAILURES | REPORT_TYPE_SITE_USER_TIME_DATE | REPORT_TYPE_DOWNLOADS;
+   }
 
    if(access(ExcludeUsers, R_OK) == 0) {
       getuexclude(ExcludeUsers,debug);
@@ -686,7 +691,7 @@ int main(int argc,char *argv[])
 
    sprintf ( sz_Download_Unsort , "%s/sarg/download.unsort", tmp);
 
-   if(strstr(ReportType,"denied") != 0) {
+   if((ReportType & REPORT_TYPE_DENIED) != 0) {
       if((fp_denied=MY_FOPEN(tmp4,"w"))==NULL) {
          fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp4,strerror(errno));
          exit(1);
@@ -694,7 +699,7 @@ int main(int argc,char *argv[])
    }
 
    if(DataFile[0]=='\0') {
-      if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) {
+      if((ReportType & REPORT_TYPE_DENIED) != 0 || (ReportType & REPORT_TYPE_AUTH_FAILURES) != 0) {
          if((fp_authfail=MY_FOPEN(tmp6,"w"))==NULL) {
             fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp6,strerror(errno));
             exit(1);
@@ -1140,7 +1145,7 @@ int main(int argc,char *argv[])
             }
          }
 
-         if(strstr(ReportType,"denied") != 0)
+         if((ReportType & REPORT_TYPE_DENIED) != 0)
             strcpy(urly,url);
 
          if(ilf!=ILF_Sarg) {
@@ -1397,7 +1402,7 @@ int main(int argc,char *argv[])
                   fprintf(fp_Download_Unsort,"%s\t%s\t%s\t%s\t%s\n",dia,hora,user,ip,download_url);
                }
 
-               if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) {
+               if((ReportType & REPORT_TYPE_DENIED) != 0 || (ReportType & REPORT_TYPE_AUTH_FAILURES) != 0) {
                   if(strstr(code,"DENIED/403") != 0) {
                      fprintf(fp_denied, "%s\t%s\t%s\t%s\t%s\n",dia,hora,user,ip,urly);
                      denied_count++;
@@ -1558,7 +1563,7 @@ int main(int argc,char *argv[])
          debuga("%s %s",text[123],arq_log);
    }
 
-   if(strstr(ReportType,"denied") != 0) {
+   if((ReportType & REPORT_TYPE_DENIED) != 0) {
       sprintf(csort,"sort -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,tmp5,tmp4);
       cstatus=system(csort);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
@@ -1577,7 +1582,7 @@ int main(int argc,char *argv[])
       gerarel();
 
    unlink(tmp2);
-   if(strstr(ReportType,"denied") != 0)
+   if((ReportType & REPORT_TYPE_DENIED) != 0)
       unlink(tmp5);
 
    if(zip[0] != '\0' && strcmp(zip,"zcat") !=0) {
index 6c095a01feff748865697906dbfade782727f3ae..cdfc35eb291cf0a8039b073ede635d0780e4d11a 100644 (file)
--- a/report.c
+++ b/report.c
@@ -212,7 +212,7 @@ void gerarel(void)
          nbytes+=accbytes;
          nelap+=accelap;
 
-         if(strstr(ReportType,"site_user_time_date") != 0) {
+         if((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
             if(!ttopen) {
                ind2++;
                strcpy(siteind,accurl);
@@ -326,7 +326,7 @@ void gerarel(void)
    totalger(wdirname, debug, outdir);
 
    if(email[0] == '\0') {
-      if(strstr(ReportType,"downloads") != 0) download_report();
+      if((ReportType & REPORT_TYPE_DOWNLOADS) != 0) download_report();
 
       if(DansGuardianConf[0] != '\0') {
          strcpy(wdirname,dirname);
@@ -339,9 +339,9 @@ void gerarel(void)
       strcpy(wdirname,dirname);
       topuser();
 
-      if(strstr(ReportType,"topsites") != 0) topsites();
+      if((ReportType & REPORT_TYPE_TOPSITES) != 0) topsites();
 
-      if(strstr(ReportType,"sites_users") != 0) siteuser();
+      if((ReportType & REPORT_TYPE_SITES_USERS) != 0) siteuser();
       gen_denied_report();
 
       strcpy(wdirname,dirname);
@@ -353,7 +353,7 @@ void gerarel(void)
 
       squidguard_report();
 
-      if(strstr(ReportType,"users_sites") != 0) htmlrel();
+      if((ReportType & REPORT_TYPE_USERS_SITES) != 0) htmlrel();
 
       make_index();
 
@@ -388,7 +388,7 @@ static void maketmp(const char *user, const char *dirname, int debug, int indexo
    char wdirname[MAXLEN];
 
    if(indexonly) return;
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    strcpy(wdirname,tmp);
    strcat(wdirname,"/");
@@ -417,7 +417,7 @@ static void maketmp_hour(const char *user, const char *dirname, int indexonly)
    char wdirname[MAXLEN];
 
    if(indexonly) return;
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    strcpy(wdirname,tmp);
    strcat(wdirname,"/");
@@ -446,7 +446,7 @@ void gravatmp(const char *oldaccuser, const char *oldurl, long long int nacc, lo
    char wdirname[MAXLEN];
 
    if(indexonly) return;
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,oldaccuser)>=sizeof(wdirname)) {
       fprintf(stderr,"SARG: Path too long %s/%s.utmp\n",tmp,oldaccuser);
@@ -485,7 +485,7 @@ static void gravatmp_hora(const char *dirname, const char *user, const char *dat
    FILE *fp_ou;
    char wdirname[MAXLEN];
 
-   if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
+   if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.htmp",tmp,user)>=sizeof(wdirname)) {
       fprintf(stderr,"SARG: Path too long %s/%s.htmp\n",tmp,user);
@@ -512,7 +512,7 @@ static void gravaporuser(const char *user, const char *dirname, const char *url,
    FILE *fp_ou;
    char wdirname[MAXLEN];
 
-   if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
+   if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,user)>=sizeof(wdirname)) {
       fprintf(stderr,"SARG: Path too long %s/%s.ip\n",tmp,user);
@@ -539,7 +539,7 @@ static void gravatmpf(const char *oldaccuser, const char *dirname, const char *o
    FILE *fp_ou;
    char wdirname[MAXLEN];
 
-   if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
+   if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,oldaccuser)>=sizeof(wdirname)) {
       fprintf(stderr,"SARG: Path too long %s/%s.utmp\n",tmp,oldaccuser);
diff --git a/sort.c b/sort.c
index d3ff056b22b5609a755d46d4974f81276e7141b4..b8a454745e006f75878a96e40d7007cf1ae21207 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -43,7 +43,7 @@ void tmpsort(void)
    char order[4]="-r";
 
    if(indexonly) return;
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    strup(UserSortField);
    if(strcmp(UserSortField,"CONNECT") == 0) {
index 4a70011decceceff8575bd157596fe59fe7ef307..5d84b56b07125b4c86073fc395ba177f224e9ecb 100644 (file)
@@ -67,7 +67,7 @@ void topsites(void)
    sprintf(general3,"%s/sarg-general3",dirname);
    sprintf(per,"%s/sarg-period",dirname);
 
-   if (strstr(ReportType,"topusers") == 0)
+   if ((ReportType & REPORT_TYPE_TOPUSERS) == 0)
       sprintf(report,"%s/index.html",dirname);
    else
       sprintf(report,"%s/topsites.html",dirname);
index bf98eca35e60fd4fe2a1994390afa8e9c797fd4d..d9ce8bbd1fd88ea82e8f9c09d2b95ccc679b7a2d 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -280,17 +280,17 @@ void topuser(void)
    fputs("<div align=\"center\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
    fputs("<tr><td><br></td><td></td></tr>\n",fp_top3);
 
-   if(strstr(ReportType,"topsites") != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"topsites.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[119]);
-   if(strstr(ReportType,"sites_users") != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"siteuser.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[85]);
+   if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"topsites.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[119]);
+   if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"siteuser.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[85]);
    if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"dansguardian.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[128]);
    if(squidguard_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=11><a href=\"squidguard.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[122]);
-   if (strstr(ReportType,"downloads") != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"download.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[125]);
-   if (strstr(ReportType,"denied") != 0 && denied_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"denied.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[118]);
-   if (strstr(ReportType,"auth_failures") != 0 && authfail_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"authfail.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[117]);
+   if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"download.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[125]);
+   if ((ReportType & REPORT_TYPE_DENIED) != 0 && denied_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"denied.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[118]);
+   if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0 && authfail_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"authfail.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[117]);
    if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"smartfilter.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[116]);
    fputs("<tr><td></td></tr>\n",fp_top3);
 
-   if (strstr(ReportType,"topuser") == 0) {
+   if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
       fputs("</body>\n</html>\n",fp_top3);
       if (fp_top3) fclose (fp_top3);
       return;
@@ -298,42 +298,42 @@ void topuser(void)
 
    strcpy(hbc10,"class=\"header\"");
 
-   if(strstr(TopUserFields,"NUM") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_NUM) == 0) {
       bzero(val1, 255);
       bzero(hbc1, 30);
    } else {
       strcpy(val1,text[100]);
       strcpy(hbc1,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"USERID") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_USERID) == 0) {
       bzero(val2, 255);
       bzero(hbc2, 30);
    } else {
       strcpy(val2,text[98]);
       strcpy(hbc2,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"CONNECT") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_CONNECT) == 0) {
       bzero(val3, 255);
       bzero(hbc3, 30);
    } else {
       strcpy(val3,text[92]);
       strcpy(hbc3,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"BYTES") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_BYTES) == 0) {
       bzero(val4, 255);
       bzero(hbc4, 30);
    } else {
       strcpy(val4,text[93]);
       strcpy(hbc4,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"SETYB") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_SETYB) == 0) {
       bzero(val11, 255);
       bzero(hbc9, 30);
    } else {
       sprintf(val11,"%%%s",text[93]);
       strcpy(hbc9,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"IN-CACHE-OUT") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) == 0) {
       bzero(val5, 255);
       bzero(hbc5, 30);
       bzero(val9, 255);
@@ -344,21 +344,21 @@ void topuser(void)
       strcpy(val9,"colspan=\"2\"");
       bzero(val10, 255);
    }
-   if(strstr(TopUserFields,"USED_TIME") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_USED_TIME) == 0) {
       bzero(val6, 255);
       bzero(hbc6, 30);
    } else {
       strcpy(val6,text[94]);
       strcpy(hbc6,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"MILISEC") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_MILISEC) == 0) {
       bzero(val7, 255);
       bzero(hbc7, 30);
    } else {
       strcpy(val7,text[95]);
       strcpy(hbc7,"class=\"header\"");
    }
-   if(strstr(TopUserFields,"%TIME") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_PTIME) == 0) {
       bzero(val8, 255);
       bzero(hbc8, 30);
    } else {
@@ -459,7 +459,7 @@ void topuser(void)
          }
       }
 
-      if(strstr(ReportType,"date_time") != 0) {
+      if((ReportType & REPORT_TYPE_DATE_TIME) != 0) {
          sprintf(ltext110,"%s",text[110]);
          for(s=ltext110; *s; ++s)
             *s=tolower(*s);
@@ -510,49 +510,49 @@ void topuser(void)
       strcpy(hbc9,"class=\"data\"");
       strcpy(hbc10,"class=\"data\"");
 
-      if(strstr(TopUserFields,"NUM") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_NUM) == 0) {
          bzero(val1, 255);
          bzero(hbc1, 30);
       }
-      if(strstr(TopUserFields,"USERID") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_USERID) == 0) {
          bzero(val2, 255);
          bzero(hbc2, 30);
       }
-      if(strstr(TopUserFields,"CONNECT") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_CONNECT) == 0) {
          bzero(wwork1, 255);
          bzero(hbc3, 30);
       }
-      if(strstr(TopUserFields,"BYTES") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_BYTES) == 0) {
          bzero(wwork2, 255);
          bzero(hbc4, 30);
       }
-      if(strstr(TopUserFields,"SETYB") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_SETYB) == 0) {
          bzero(val3, 255);
          bzero(hbc5, 30);
       }
 
-      if(strstr(TopUserFields,"IN-CACHE-OUT") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) == 0) {
          bzero(val4, 255);
          bzero(hbc6, 30);
       }
-      if(strstr(TopUserFields,"IN-CACHE-OUT") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) == 0) {
          bzero(val5, 255);
          bzero(hbc7, 30);
       }
-      if(strstr(TopUserFields,"USED_TIME") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_USED_TIME) == 0) {
          bzero(val6, 255);
          bzero(hbc8, 30);
       }
-      if(strstr(TopUserFields,"MILISEC") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_MILISEC) == 0) {
          bzero(wwork3, 255);
          bzero(hbc9, 30);
       }
-      if(strstr(TopUserFields,"%TIME") == 0) {
+      if((TopUserFields & TOPUSERFIELDS_PTIME) == 0) {
          bzero(val7, 255);
          bzero(hbc10, 30);
       }
 
-      if(strstr(ReportType,"users_sites") == 0) {
+      if((ReportType & REPORT_TYPE_USERS_SITES) == 0) {
          href1[0]='\0';
          href1end[0]='\0';
       }
@@ -595,33 +595,33 @@ void topuser(void)
          sprintf(val6,"%s",buildtime(ttnelap));
          sprintf(val7,"%3.2f%%",perc2);
 
-         if(strstr(TopUserFields,"CONNECT") == 0) {
+         if((TopUserFields & TOPUSERFIELDS_CONNECT) == 0) {
             bzero(wwork1, 255);
             bzero(hbc1, 30);
          }
-         if(strstr(TopUserFields,"BYTES") == 0) {
+         if((TopUserFields & TOPUSERFIELDS_BYTES) == 0) {
             bzero(wwork2, 255);
             bzero(hbc2, 30);
          }
-         if(strstr(TopUserFields,"IN-CACHE-OUT") == 0) {
+         if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) == 0) {
             bzero(val4, 255);
             bzero(val5, 255);
             bzero(hbc3, 30);
             bzero(hbc4, 30);
          }
-         if(strstr(TopUserFields,"USED_TIME") == 0) {
+         if((TopUserFields & TOPUSERFIELDS_USED_TIME) == 0) {
             bzero(val6, 255);
             bzero(hbc5, 30);
          }
-         if(strstr(TopUserFields,"MILISEC") == 0) {
+         if((TopUserFields & TOPUSERFIELDS_MILISEC) == 0) {
             bzero(wwork3, 255);
             bzero(hbc6, 30);
          }
 
-         if(strstr(ReportType,"date_time") != 0) {
-           if(strstr(TopUserFields,"TOTAL") != 0)
+         if((ReportType & REPORT_TYPE_DATE_TIME) != 0) {
+           if((TopUserFields & TOPUSERFIELDS_TOTAL) != 0)
                sprintf(preg,"<tr><td></td><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[107],hbc1,wwork1,hbc2,wwork2,hbc3,val4,hbc4,val5,hbc5,val6,hbc6,wwork3);
-        } else if(strstr(TopUserFields,"TOTAL") != 0)
+        } else if((TopUserFields & TOPUSERFIELDS_TOTAL) != 0)
             sprintf(preg,"<tr><td></td><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[107],hbc1,wwork1,hbc2,wwork2,hbc3,val4,hbc4,val5,hbc5,val6,hbc6,wwork3);
       }
 
@@ -639,33 +639,33 @@ void topuser(void)
    strcpy(wwork2,fixnum(tnbytes,1));
    strcpy(wwork3,fixnum2(twork2,1));
 
-   if(strstr(TopUserFields,"CONNECT") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_CONNECT) == 0) {
       bzero(wwork1, 255);
       bzero(hbc1, 30);
    }
-   if(strstr(TopUserFields,"BYTES") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_BYTES) == 0) {
       bzero(wwork2, 255);
       bzero(hbc2, 30);
    }
-   if(strstr(TopUserFields,"IN-CACHE-OUT") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) == 0) {
       bzero(val4, 255);
       bzero(val5, 255);
       bzero(hbc3, 30);
       bzero(hbc4, 30);
    }
-   if(strstr(TopUserFields,"USED_TIME") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_USED_TIME) == 0) {
       bzero(val6, 255);
       bzero(hbc5, 30);
    }
-   if(strstr(TopUserFields,"MILISEC") == 0) {
+   if((TopUserFields & TOPUSERFIELDS_MILISEC) == 0) {
       bzero(wwork3, 255);
       bzero(hbc6, 30);
    }
 
    if(ntopuser) {
-      if((strstr(ReportType,"date_time") != 0 && strstr(TopUserFields,"AVERAGE") != 0))
+      if(((ReportType & REPORT_TYPE_DATE_TIME) != 0 && (TopUserFields & TOPUSERFIELDS_AVERAGE) != 0))
          fprintf(fp_top3,"<tr><td></td><th></th><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
-      else if(strstr(TopUserFields,"AVERAGE") != 0)
+      else if((TopUserFields & TOPUSERFIELDS_AVERAGE) != 0)
          fprintf(fp_top3,"<tr><td></td><th></th><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
    }
 
index 9d7b62db20a775b7856ef4c21b55de80cf4530e6..e9e441732966d68ad0bfa9bdbea34c1209605a53 100644 (file)
--- a/totday.c
+++ b/totday.c
@@ -48,7 +48,7 @@ void day_totalize(const char *tmp, const char *user, int indexonly)
    struct getwordstruct gwarea;
 
    if(indexonly) return;
-   if(strstr(ReportType,"users_sites") == 0) return;
+   if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
    sprintf(wdirname,"%s/%s.htmp",tmp,user);
    sprintf(arqout,"%s/%s.day",tmp,user);