From: Frédéric Marchal Date: Thu, 28 Jan 2010 13:34:23 +0000 (+0000) Subject: Pre-parse variables Index and IndexTree X-Git-Tag: v2.3-pre2~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0349fa248dcfa9957667731b8bcdbcf52d5f0e29;p=thirdparty%2Fsarg.git Pre-parse variables Index and IndexTree --- diff --git a/authfail.c b/authfail.c index 401c0ef..895d55e 100644 --- a/authfail.c +++ b/authfail.c @@ -100,7 +100,7 @@ void authfail_report(void) fprintf(fp_ou,"\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,".."); diff --git a/dansguardian_report.c b/dansguardian_report.c index 3b6a411..92808f9 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -88,7 +88,7 @@ void dansguardian_report(void) fprintf(fp_ou,"\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,".."); diff --git a/denied.c b/denied.c index ba9d432..7712637 100644 --- a/denied.c +++ b/denied.c @@ -87,7 +87,7 @@ void gen_denied_report(void) fprintf(fp_ou,"\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, ".."); diff --git a/download.c b/download.c index 0cf96bd..45c84d8 100644 --- a/download.c +++ b/download.c @@ -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, ".."); diff --git a/getconf.c b/getconf.c index 5f30ea2..ff84257 100644 --- 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 574220c..b74a52b 100644 --- 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,"%s",PrivacyStringColor,PrivacyString); else { - if(strcmp(IndexTree,"date") == 0) + if(IndexTree == INDEX_TREE_DATE) sprintf(tmp6,"../%s",ImageFile); else strcpy(tmp6,"../../images"); diff --git a/include/conf.h b/include/conf.h index 785801d..9fac0f8 100755 --- a/include/conf.h +++ b/include/conf.h @@ -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 f8a86d2..ab272bc 100644 --- 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 d9d64ef..6c068c6 100644 --- 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); } diff --git a/repday.c b/repday.c index 0a0f250..87794f7 100644 --- a/repday.c +++ b/repday.c @@ -75,7 +75,7 @@ void report_day(const char *user) fprintf(fp_ou,"\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, "../.."); diff --git a/report.c b/report.c index 4315749..21dc1d4 100644 --- a/report.c +++ b/report.c @@ -252,7 +252,7 @@ void gerarel(void) fprintf(fp_tt,"\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, "../.."); diff --git a/siteuser.c b/siteuser.c index 6484664..bc20ffe 100644 --- a/siteuser.c +++ b/siteuser.c @@ -98,7 +98,7 @@ void siteuser(void) fprintf(fp_ou,"\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, ".."); diff --git a/squidguard_report.c b/squidguard_report.c index a062aec..0c09961 100644 --- a/squidguard_report.c +++ b/squidguard_report.c @@ -88,7 +88,7 @@ void squidguard_report(void) fprintf(fp_ou,"\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,".."); diff --git a/topsites.c b/topsites.c index 5d84b56..9450c37 100644 --- a/topsites.c +++ b/topsites.c @@ -223,7 +223,7 @@ void topsites(void) fprintf(fp_ou,"\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, ".."); diff --git a/topuser.c b/topuser.c index d9ce8bb..19db7e2 100644 --- a/topuser.c +++ b/topuser.c @@ -260,7 +260,7 @@ void topuser(void) fprintf(fp_top3,"\n"); write_logo_image(fp_top3); - if(strcmp(IndexTree,"date") == 0) + if(IndexTree == INDEX_TREE_DATE) show_sarg(fp_top3, "../../.."); else show_sarg(fp_top3, ".."); diff --git a/useragent.c b/useragent.c index b438b80..2f83b8b 100644 --- a/useragent.c +++ b/useragent.c @@ -149,7 +149,7 @@ void useragent(void) fprintf(fp_ht,"\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 e16aa8a..f0eeff4 100644 --- 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) {