]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Pre-parse variables Index and IndexTree
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 28 Jan 2010 13:34:23 +0000 (13:34 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 28 Jan 2010 13:34:23 +0000 (13:34 +0000)
17 files changed:
authfail.c
dansguardian_report.c
denied.c
download.c
getconf.c
html.c
include/conf.h
index.c
log.c
repday.c
report.c
siteuser.c
squidguard_report.c
topsites.c
topuser.c
useragent.c
util.c

index 401c0ef4f9799343420e0502a63bc4e5315c4758..895d55e10086f92e85a8353599b68e67ebd9aef8 100644 (file)
@@ -100,7 +100,7 @@ void authfail_report(void)
    fprintf(fp_ou,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou,"..");
index 3b6a411b1ece2b7a31f88078388e55a79ddc69fd..92808f920d098b9d781aafcf88d6d168175034f4 100644 (file)
@@ -88,7 +88,7 @@ void dansguardian_report(void)
    fprintf(fp_ou,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou,"..");
index ba9d432b84407a993a095158808c5f8e2bc79446..7712637cdcbe3c813d76464006706766d3b756b0 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -87,7 +87,7 @@ void gen_denied_report(void)
    fprintf(fp_ou,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou, "..");
index 0cf96bd47732ddc82887aed1680a558faf96615f..45c84d85e3ef75a85c774e9327b14b00099a68cc 100644 (file)
@@ -94,7 +94,7 @@ void download_report(void)
 
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou, "..");
index 5f30ea2229c30fae54b8f9b23a5d544092763a55..ff842570a4a5df02839098059d6ffd3da4b7a859 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -97,6 +97,19 @@ struct param_list userreportfields_values[]=
    {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
 };
 
+struct param_list index_values[]=
+{
+   {"yes",INDEX_YES,~INDEX_YES},
+   {"no",INDEX_NO,~INDEX_NO},
+   {"only",INDEX_ONLY,~INDEX_ONLY},
+};
+
+struct param_list index_tree_values[]=
+{
+   {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE},
+   {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE},
+};
+
 static int is_param(const char *param,const char *buf)
 {
    int plen;
@@ -399,9 +412,9 @@ static void parmtest(char *buf)
 
    if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
 
-   if (getparam_string("index_tree",buf,IndexTree,sizeof(IndexTree))>0) return;
+   if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return;
 
-   if (getparam_string("index",buf,Index,sizeof(Index))>0) return;
+   if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return;
 
    if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
 
diff --git a/html.c b/html.c
index 574220c7fbd56098a83f4f097d6e175b0079994b..b74a52b86dbbed134306e65b5b9c26901cb01c62 100644 (file)
--- a/html.c
+++ b/html.c
@@ -233,7 +233,7 @@ void htmlrel(void)
 
       write_logo_image(fp_ou);
 
-      if(strcmp(IndexTree,"date") == 0)
+      if(IndexTree == INDEX_TREE_DATE)
          show_sarg(fp_ou, "../../../..");
       else
          show_sarg(fp_ou, "../..");
@@ -373,7 +373,7 @@ void htmlrel(void)
          if(Privacy)
             sprintf(httplink,"<span style=\"color:%s;\">%s</span>",PrivacyStringColor,PrivacyString);
          else {
-            if(strcmp(IndexTree,"date") == 0)
+            if(IndexTree == INDEX_TREE_DATE)
                sprintf(tmp6,"../%s",ImageFile);
             else
                strcpy(tmp6,"../../images");
index 785801d3ebc167e89254a78a5803e637dbd8ef8d..9fac0f8ba313ef323a2ef80163313140e02d6fd8 100755 (executable)
@@ -180,6 +180,13 @@ int mkstemps(char *template, int suffixlen);
 #define USERREPORTFIELDS_TOTAL        0x0080UL
 #define USERREPORTFIELDS_AVERAGE      0x0100UL
 
+#define INDEX_YES  0x0001UL
+#define INDEX_NO   0x0002UL
+#define INDEX_ONLY 0x0004UL
+
+#define INDEX_TREE_DATE 0x0001UL
+#define INDEX_TREE_FILE 0x0002UL
+
 FILE *fp_tt;
 
 char outdir[MAXLEN];
@@ -213,7 +220,7 @@ char cduntil[30];
 int LastLog;
 int RemoveTempFiles;
 char ReplaceIndex[256];
-char Index[20];
+unsigned long int Index;
 int OverwriteReport;
 char u2[255];
 char RecordsWithoutUser[20];
@@ -318,7 +325,7 @@ char hbc7[30];
 char hbc8[30];
 char hbc9[30];
 char hbc10[30];
-char IndexTree[10];
+unsigned long int IndexTree;
 int UserAuthentication;
 char AuthUserFile[255];
 char AuthName[512];
diff --git a/index.c b/index.c
index f8a86d265541f4b46a16a59580435f87d8b55c84..ab272bce108c4a6e76a6d998cfcf2f67c5c5a963 100644 (file)
--- a/index.c
+++ b/index.c
@@ -39,7 +39,7 @@ void make_index(void)
 
    if(LastLog > 0) mklastlog(outdir);
 
-   if(strcmp(Index,"no") == 0) {
+   if(Index == INDEX_NO) {
       sprintf(wdir,"%sindex.html",outdir);
       if(access(wdir, R_OK) == 0) unlink(wdir);
       return;
@@ -51,7 +51,7 @@ void make_index(void)
    dirp = opendir(outdir);
    while ((direntp = readdir( dirp )) != NULL) {
       if(isdigit(direntp->d_name[0]) && isdigit(direntp->d_name[1])) {
-         if(strcmp(IndexTree,"date") == 0)
+         if(IndexTree == INDEX_TREE_DATE)
             file_index_to_date_index(direntp->d_name);
          else
             date_index_to_file_index(direntp->d_name);
@@ -59,7 +59,7 @@ void make_index(void)
    }
    closedir(dirp);
 
-   if(strcmp(IndexTree,"date") == 0) {
+   if(IndexTree == INDEX_TREE_DATE) {
       make_date_index();
    } else {
       make_file_index();
diff --git a/log.c b/log.c
index d9d64eff996d3372ee94a0ecd7deb97c47223f22..6c068c643aeefca5ee17132d8d84f588cacc36d1 100644 (file)
--- a/log.c
+++ b/log.c
@@ -170,7 +170,7 @@ int main(int argc,char *argv[])
    OverwriteReport=0;
    RemoveTempFiles=1;
    strcpy(ReplaceIndex,"index.html");
-   strcpy(Index,"yes");
+   Index=INDEX_YES;
    strcpy(RecordsWithoutUser,"ip");
    UseComma=0;
    strcpy(MailUtility,"mailx");
@@ -219,7 +219,7 @@ int main(int argc,char *argv[])
    Graphs=1;
    strcpy(Ulimit,"20000");
    strcpy(NtlmUserFormat,"domainname+username");
-   strcpy(IndexTree,"file");
+   IndexTree=INDEX_TREE_FILE;
    strcpy(RealtimeTypes,"GET,PUT,CONNECT");
    strcpy(RealtimeUnauthRec,"show");
    SquidguardIgnoreDate=0;
@@ -460,7 +460,7 @@ int main(int argc,char *argv[])
       exit(0);
    }
 
-   if(strcmp(IndexTree,"file") == 0)
+   if(IndexTree == INDEX_TREE_FILE)
       strcpy(ImageFile,"../images");
    else
       strcpy(ImageFile,"../../../images");
@@ -515,7 +515,7 @@ int main(int argc,char *argv[])
          indexonly++;
    }
    if(strcmp(ExcludeUsers,"indexonly") == 0) indexonly++;
-   if(strcmp(Index,"only") == 0) indexonly++;
+   if(Index == INDEX_ONLY) indexonly++;
 
    if(MaxElapsed[0] != '\0') max_elapsed=atol(MaxElapsed);
 
@@ -1192,7 +1192,7 @@ int main(int argc,char *argv[])
             if(strncmp(df,"e",1) == 0)
                sprintf(tbuf, "%02d%s%04d", t->tm_mday, mes, t->tm_year+1900);
             if(strncmp(df,"w",1) == 0) {
-               strcpy(IndexTree,"file");
+               IndexTree=INDEX_TREE_FILE;
                strftime(tbuf, sizeof(tbuf), "%Y.%U", t);
             }
 
index 0a0f2504a6116d3dc4643b3405568549f03efaa0..87794f7316ec45851bbb20128961f8fbdacdd140 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -75,7 +75,7 @@ void report_day(const char *user)
    fprintf(fp_ou,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../../..");
    else
       show_sarg(fp_ou, "../..");
index 431574907f836eaaa77d60871e6eb62b1b27166e..21dc1d46ac95f09bccd13a356e0245a768e65991 100644 (file)
--- a/report.c
+++ b/report.c
@@ -252,7 +252,7 @@ void gerarel(void)
                fprintf(fp_tt,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
                write_logo_image(fp_tt);
 
-               if(strcmp(IndexTree,"date") == 0)
+               if(IndexTree == INDEX_TREE_DATE)
                   show_sarg(fp_tt, "../../../..");
                else
                   show_sarg(fp_tt, "../..");
index 6484664b98bf6d060b0c918ae4ca29ab6275f715..bc20ffe356f550141442c034d236a9583e4cb322 100644 (file)
@@ -98,7 +98,7 @@ void siteuser(void)
    fprintf(fp_ou,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou, "..");
index a062aecd355cf54ea0f154961881cf55de0e9fae..0c09961d591f477087f65a57749440932db276bf 100644 (file)
@@ -88,7 +88,7 @@ void squidguard_report(void)
    fprintf(fp_ou,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou, "../../..");
    else
       show_sarg(fp_ou,"..");
index 5d84b56b07125b4c86073fc395ba177f224e9ecb..9450c377cfc7859b29ae8c67e042f70efd1cd620 100644 (file)
@@ -223,7 +223,7 @@ void topsites(void)
    fprintf(fp_ou,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ou);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ou,"../../..");
    else
       show_sarg(fp_ou, "..");
index d9ce8bbd1fd88ea82e8f9c09d2b95ccc679b7a2d..19db7e23355efda9ff04736757017f20f2da5c64 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -260,7 +260,7 @@ void topuser(void)
    fprintf(fp_top3,"</head>\n<body class=\"body\">");
    write_logo_image(fp_top3);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_top3, "../../..");
    else
       show_sarg(fp_top3, "..");
index b438b80b86c8b4b6934fb213b4822e5d3fdeebac..2f83b8b6d5b69fe60e12bed4f64e7fed07f28381 100644 (file)
@@ -149,7 +149,7 @@ void useragent(void)
    fprintf(fp_ht,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ht);
 
-   if(strcmp(IndexTree,"date") == 0)
+   if(IndexTree == INDEX_TREE_DATE)
       show_sarg(fp_ht, "../../..");
    else
       show_sarg(fp_ht,"..");
diff --git a/util.c b/util.c
index e16aa8ab66d4ac4e74d1812d5eb0ad57ac79c25a..f0eeff48a004d63784d70dfc6ebd54783fefbffd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -875,7 +875,7 @@ void vrfydir(const char *per1, const char *addr, const char *site, const char *u
    time_t curtime;
    struct tm *loctm;
 
-   if(strcmp(IndexTree,"date") == 0) {
+   if(IndexTree == INDEX_TREE_DATE) {
       bzero(y1,sizeof(y1));
       bzero(y2,sizeof(y2));
       bzero(d1,sizeof(d1));
@@ -942,7 +942,7 @@ void vrfydir(const char *per1, const char *addr, const char *site, const char *u
 
    strcpy(dirname,wdir);
 
-   if(strcmp(IndexTree,"date") != 0) {
+   if(IndexTree != INDEX_TREE_DATE) {
       if(!OverwriteReport) {
          while(num) {
             if(access(wdir,R_OK) == 0) {