From 5f3cfd1df66d0940e77a2ad8cb10dba1bcbfd44f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Wed, 8 Jul 2009 10:01:56 +0000 Subject: [PATCH] Moved all the functions declarations from conf.h to defs.h for consistency. Fixed bug #2089451. --- auth.c | 1 + authfail.c | 1 + charset.c | 1 + convlog.c | 1 + css.c | 1 + dansguardian_log.c | 1 + dansguardian_report.c | 1 + datafile.c | 1 + decomp.c | 1 + denied.c | 1 + download.c | 1 + email.c | 1 + exclude.c | 1 + getconf.c | 1 + grepday.c | 1 + html.c | 1 + include/conf.h | 158 ------------------------- include/defs.h | 164 ++++++++++++++++++++++++-- include/info.h | 2 +- index.c | 1 + indexonly.c | 1 + ip2name.c | 1 + language.c | 1 + lastlog.c | 1 + log.c | 1 + realtime.c | 1 + repday.c | 1 + report.c | 261 ++++++++++++++++++++++-------------------- siteuser.c | 1 + smartfilter.c | 1 + sort.c | 1 + splitlog.c | 1 + squidguard_log.c | 67 ++++++----- squidguard_report.c | 1 + topsites.c | 1 + topuser.c | 1 + totday.c | 1 + totger.c | 1 + usage.c | 1 + useragent.c | 1 + util.c | 14 +++ 41 files changed, 374 insertions(+), 327 deletions(-) diff --git a/auth.c b/auth.c index 6bbf383..3cb5d09 100644 --- a/auth.c +++ b/auth.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void htaccess(const char *name) { diff --git a/authfail.c b/authfail.c index e0a4239..93c2b8f 100644 --- a/authfail.c +++ b/authfail.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void authfail_report(void) { diff --git a/charset.c b/charset.c index 1bf0251..d45cca0 100644 --- a/charset.c +++ b/charset.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void ccharset(char *CharSet) { diff --git a/convlog.c b/convlog.c index ef10943..ccc8e6e 100644 --- a/convlog.c +++ b/convlog.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void convlog(const char *arq, char *df, int dfrom, int duntil) { diff --git a/css.c b/css.c index 565048c..ed94893 100644 --- a/css.c +++ b/css.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void css(FILE *fp_css) { diff --git a/dansguardian_log.c b/dansguardian_log.c index e8876df..866e393 100644 --- a/dansguardian_log.c +++ b/dansguardian_log.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void dansguardian_log(void) { diff --git a/dansguardian_report.c b/dansguardian_report.c index e877180..aafaec2 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void dansguardian_report(void) { diff --git a/datafile.c b/datafile.c index 850230f..ea2e21f 100644 --- a/datafile.c +++ b/datafile.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void saverecs(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache); void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart); diff --git a/decomp.c b/decomp.c index 2f9fb71..50ca8a5 100644 --- a/decomp.c +++ b/decomp.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void decomp(char *arq, char *zip, const char *tmp) { diff --git a/denied.c b/denied.c index bdda37e..e45fd13 100644 --- a/denied.c +++ b/denied.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void gen_denied_report(void) { diff --git a/download.c b/download.c index 82f61cc..8970837 100644 --- a/download.c +++ b/download.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void download_report(void) { diff --git a/email.c b/email.c index 204da35..ec0af2c 100644 --- a/email.c +++ b/email.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir) { diff --git a/exclude.c b/exclude.c index 1d0ad4f..d49678f 100644 --- a/exclude.c +++ b/exclude.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" int vhexclude(const char *excludefile, const char *url) { diff --git a/getconf.c b/getconf.c index a81b1e7..d1e0e08 100644 --- a/getconf.c +++ b/getconf.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" extern numlist hours, weekdays; diff --git a/grepday.c b/grepday.c index a4b6f6d..7ed301e 100644 --- a/grepday.c +++ b/grepday.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" int blue; int white; diff --git a/html.c b/html.c index 6a24f90..71c7a89 100644 --- a/html.c +++ b/html.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void htmlrel(void) { diff --git a/include/conf.h b/include/conf.h index fa77843..22820b3 100755 --- a/include/conf.h +++ b/include/conf.h @@ -342,161 +342,3 @@ typedef struct DIR *dirp; struct dirent *direntp; - -// auth.c -void htaccess(const char *name); - -// authfail.c -void authfail_report(void); - -// charset.c -void ccharset(char *CharSet); - -// convlog.c -void convlog(const char *arq, char *df, int dfrom, int duntil); - -// css.c -void css(FILE *fp_css); - -// dansguardian_log.c -void dansguardian_log(void); - -// dansguardian_report.c -void dansguardian_report(void); - -// datafile.c -void data_file(char *tmp); - -// decomp.c -void decomp(char *arq, char *zip, const char *tmp); -void recomp(const char *arq, const char *zip) ; - -// denied.c -void gen_denied_report(void); - -// download.c -void download_report(void); - -// email.c -int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir); - -// exclude.c -int vhexclude(const char *excludefile, const char *url); -int vuexclude(const char *excludeuser, const char *user); - -// getconf.c -void getconf(void); - -// grepday.c -void greport_day(const char *user); - -// html.c -void htmlrel(void); - -// indexonly.c -void index_only(const char *dirname,int debug); - -// ip2name.c -void ip2name(char *ip,int ip_len); -void name2ip(char *name); - -// language.c -void language_load(const char *language); - -// lastlog.c -void mklastlog(const char *outdir); - -// index.c -void make_index(void); - -// realtime.c -void realtime(void); - -// repday.c -void report_day(const char *user); - -// report.c -void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); -void gerarel(void); - -// siteuser.c -void siteuser(void); - -// smartfilter.c -void smartfilter_report(void); - -// sort.c -void sort_users_log(const char *tmp, int debug); -void tmpsort(void); - -// splitlog.c -void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert); - -// squidguard_log.c -void squidguard_log(void); - -// squidguard_report.c -void squidguard_report(void); - -// topsites.c -void topsites(void); - -// topuser.c -void topuser(void); - -// totday.c -void day_totalize(const char *tmp, const char *user, int indexonly); - -// totger.c -int totalger(const char *dirname, int debug, const char *outdir); - -// usage.c -void usage(const char *prog); - -// useragent.c -void useragent(void); - -// util.c -int getword(char *word, int limit, char *line, int stop); -int getword_multisep(char *word, int limit, char *line, int stop); -int getword3(char *word, int limit, char *line, int stop); -void name_month(char *month,int month_len); -void conv_month_name(char *month); -void buildymd(const char *dia, const char *mes, const char *ano, char *wdata); -void date_from(char *date, char *dfrom, char *duntil); -int getnumlist( char *, numlist *, const int, const int ); -void fixip(char *ip); -char *fixnum(long long int value, int n); -char *fixnum2(long long int value, int n); -void fixnone(char *str); -void fixper(char *tbuf, char *period, const char *duntil); -char *fixtime(long int elap); -void show_info(FILE *fp_ou); -void show_sarg(FILE *fp_ou, const char *ind); -void write_html_header(FILE *fp_ou, const char * ind); -void write_html_trailer(FILE *fp_ou); -char *subs(char *str, char *from, char *to); -void conv_month(char *month); -void debuga(const char *msg); -void debugaz(const char *head, const char *msg); -void my_lltoa(unsigned long long int n, char s[], int len); -char *get_size(const char *path, const char *file); -void url_module(char *url, char *w2); -void strip_latin(char *line); -char *buildtime(long long int elap); -void obtdate(const char *dirname, const char *name, char *data); -void obtuser(const char *dirname, const char *name, char *tuser); -void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media); -void version(void); -int vercode(const char *code); -void load_excludecodes(void); -void my_mkdir(const char *name); -int testvaliduserchar(const char *user); -char *strlow(char *string); -char *strup(char *string); -void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata); -void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form); -void gperiod(void); -void removetmp(const char *outdir); -void zdate(char *ftime, const char *DateFormat); -void baddata(void); diff --git a/include/defs.h b/include/defs.h index e1d2124..95aa698 100755 --- a/include/defs.h +++ b/include/defs.h @@ -1,8 +1,158 @@ -void maketmp(char *user, char *dirname, int debug, int indexonly); -void maketmp_hour(char *user, char *dirname, int indexonly); +// auth.c +void htaccess(const char *name); + +// authfail.c +void authfail_report(void); + +// charset.c +void ccharset(char *CharSet); + +// convlog.c +void convlog(const char *arq, char *df, int dfrom, int duntil); + +// css.c +void css(FILE *fp_css); + +// dansguardian_log.c +void dansguardian_log(void); + +// dansguardian_report.c +void dansguardian_report(void); + +// datafile.c +void data_file(char *tmp); + +// decomp.c +void decomp(char *arq, char *zip, const char *tmp); +void recomp(const char *arq, const char *zip) ; + +// denied.c +void gen_denied_report(void); + +// download.c +void download_report(void); + +// email.c +int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir); + +// exclude.c +int vhexclude(const char *excludefile, const char *url); +int vuexclude(const char *excludeuser, const char *user); + +// getconf.c +void getconf(void); + +// grepday.c +void greport_day(const char *user); + +// html.c +void htmlrel(void); + +// indexonly.c +void index_only(const char *dirname,int debug); + +// ip2name.c +void ip2name(char *ip,int ip_len); +void name2ip(char *name); + +// language.c +void language_load(const char *language); + +// lastlog.c +void mklastlog(const char *outdir); + +// index.c +void make_index(void); + +// realtime.c +void realtime(void); + +// repday.c +void report_day(const char *user); + +// report.c void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); -void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly); -void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); -void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly); -void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache); -void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart); +void gerarel(void); + +// siteuser.c +void siteuser(void); + +// smartfilter.c +void smartfilter_report(void); + +// sort.c +void sort_users_log(const char *tmp, int debug); +void tmpsort(void); + +// splitlog.c +void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert); + +// squidguard_log.c +void squidguard_log(void); + +// squidguard_report.c +void squidguard_report(void); + +// topsites.c +void topsites(void); + +// topuser.c +void topuser(void); + +// totday.c +void day_totalize(const char *tmp, const char *user, int indexonly); + +// totger.c +int totalger(const char *dirname, int debug, const char *outdir); + +// usage.c +void usage(const char *prog); + +// useragent.c +void useragent(void); + +// util.c +int getword(char *word, int limit, char *line, int stop); +int getword_multisep(char *word, int limit, char *line, int stop); +int getword3(char *word, int limit, char *line, int stop); +void name_month(char *month,int month_len); +void conv_month_name(char *month); +void buildymd(const char *dia, const char *mes, const char *ano, char *wdata); +void date_from(char *date, char *dfrom, char *duntil); +int getnumlist( char *, numlist *, const int, const int ); +void fixip(char *ip); +char *fixnum(long long int value, int n); +char *fixnum2(long long int value, int n); +void fixnone(char *str); +void fixper(char *tbuf, char *period, const char *duntil); +char *fixtime(long int elap); +void show_info(FILE *fp_ou); +void show_sarg(FILE *fp_ou, const char *ind); +void write_html_header(FILE *fp_ou, const char * ind); +void write_html_trailer(FILE *fp_ou); +char *subs(char *str, char *from, char *to); +void conv_month(char *month); +void debuga(const char *msg); +void debugaz(const char *head, const char *msg); +void my_lltoa(unsigned long long int n, char s[], int len); +char *get_size(const char *path, const char *file); +void url_module(char *url, char *w2); +void strip_latin(char *line); +char *buildtime(long long int elap); +void obtdate(const char *dirname, const char *name, char *data); +void obtuser(const char *dirname, const char *name, char *tuser); +void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media); +void version(void); +int vercode(const char *code); +void load_excludecodes(void); +void my_mkdir(const char *name); +int testvaliduserchar(const char *user); +char *strlow(char *string); +char *strup(char *string); +void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata); +void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form); +void gperiod(void); +void removetmp(const char *outdir); +void zdate(char *ftime, const char *DateFormat); +void baddata(void); +char *get_param_value(const char *param,char *line); diff --git a/include/info.h b/include/info.h index b51977c..c8cd1c9 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION "2.2.5 Jul-07-2009" +#define VERSION "2.2.5 Jul-08-2009" #define PGM "sarg" #define URL "http://sarg.sourceforge.net" diff --git a/index.c b/index.c index 60b8456..22bd7cb 100644 --- a/index.c +++ b/index.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void make_index(void) { diff --git a/indexonly.c b/indexonly.c index b409665..2f3b9c3 100644 --- a/indexonly.c +++ b/indexonly.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void index_only(const char *dirname,int debug) diff --git a/ip2name.c b/ip2name.c index 462b045..5b0eb5f 100644 --- a/ip2name.c +++ b/ip2name.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void ip2name(char *ip,int ip_len) { diff --git a/language.c b/language.c index 8e58a83..625747b 100644 --- a/language.c +++ b/language.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void language_load(const char *language) { diff --git a/lastlog.c b/lastlog.c index fb48e2f..1c9a893 100644 --- a/lastlog.c +++ b/lastlog.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void mklastlog(const char *outdir) { diff --git a/log.c b/log.c index c6147c2..cea7892 100644 --- a/log.c +++ b/log.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" #define LEGACY_WRITE_USER #define LEGACY_WRITE_DOWNLOAD diff --git a/realtime.c b/realtime.c index 770d52d..ba72653 100755 --- a/realtime.c +++ b/realtime.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" int getdata(char *, FILE *); void datashow(char *); diff --git a/repday.c b/repday.c index 87b8786..85c5543 100644 --- a/repday.c +++ b/repday.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" extern numlist hours; diff --git a/report.c b/report.c index 57e1042..02ffdc5 100644 --- a/report.c +++ b/report.c @@ -26,6 +26,14 @@ #include "include/conf.h" #include "include/defs.h" +static void maketmp(const char *user, const char *dirname, int debug, int indexonly); +static void maketmp_hour(const char *user, const char *dirname, int indexonly); +static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly); +static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); +static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly); +static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache); +static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart); + void gerarel(void) { @@ -80,7 +88,7 @@ void gerarel(void) if((strcmp(direntp->d_name+dlen,logext) != 0) || (strncmp(direntp->d_name,"download.log",12) == 0) || (strncmp(direntp->d_name,"denied.log",10) == 0) || - (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0)) + (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0)) continue; if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) { fprintf(stderr, "SARG: (report) directory entry too long: %s/%s\n",tmp,direntp->d_name); @@ -168,7 +176,7 @@ void gerarel(void) incache=0; oucache=0; } - } else { + } else { if(strcmp(oldurl,accurl) != 0 || strcmp(oldaccuser,accuser) != 0){ strcpy(oldmsg,"OK"); if(strstr(oldacccode,"DENIED") != 0) @@ -182,134 +190,134 @@ void gerarel(void) nelap=0; incache=0; oucache=0; - if(strcmp(oldaccuser,accuser) != 0) - ind2=0; - } - } - nacc++; - nbytes+=my_atoll(accbytes); - nelap+=my_atoll(accelap); - - if(strstr(ReportType,"site_user_time_date") != 0) { - if(!ttopen) { - ind2++; - strcpy(siteind,accurl); - str=siteind; - for(z1=0; str[z1]; z1++) { - if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' || - str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$') - str[z1]='_'; + if(strcmp(oldaccuser,accuser) != 0) + ind2=0; } - sprintf(arqtt,"%s/%s",dirname,accuser); - if(access(arqtt, R_OK) != 0) - my_mkdir(arqtt); - sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind); - if(strlen(arqtt) > 255) { - strncpy(val7,arqtt,255); - bzero(arqtt,MAXLEN); - strcpy(arqtt,val7); - } - if ((fp_tt = fopen(arqtt, "w")) == 0) { - fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt); - exit(1); - } - ttopen=1; - - if(strcmp(Privacy,"yes") == 0) - sprintf(httplink,"%s", \ - FontSize,PrivacyStringColor,PrivacyString,PrivacyString); - else - sprintf(httplink,"%s",FontSize,accurl,accurl); - - sprintf(ltext110,"%s",text[110]); - for(s=ltext110; *s; ++s) - *s=tolower(*s); - - fprintf(fp_tt, "\n\n\n \n",CharSet); - css(fp_tt); - fputs("\n",fp_tt); - fprintf(fp_tt,"\n",BgColor,TxColor,BgImage); - if(strlen(LogoImage) > 0) fprintf(fp_tt, "
\n\n\n
 %s
\n",LogoImage,Width,Height,LogoText); - - if(strcmp(IndexTree,"date") == 0) - show_sarg(fp_tt, "../../../.."); - else - show_sarg(fp_tt, "../.."); - - fputs("
\n",fp_tt); - fprintf(fp_tt,"\n",Title); - - strcpy(u2,user); - if(strcmp(Ip2Name,"yes") == 0) - ip2name(u2,sizeof(u2)); - if(UserTabFile[0] != '\0') { - sprintf(warea,":%s:",u2); - if((str=(char *) strstr(userfile,warea)) != (char *) NULL ) { - z1=0; - str2=(char *) strstr(str+1,":"); - str2++; - bzero(name, MAXLEN); - while(str2[z1] != ':') { - name[z1]=str2[z1]; - z1++; - } + } + nacc++; + nbytes+=my_atoll(accbytes); + nelap+=my_atoll(accelap); + + if(strstr(ReportType,"site_user_time_date") != 0) { + if(!ttopen) { + ind2++; + strcpy(siteind,accurl); + str=siteind; + for(z1=0; str[z1]; z1++) { + if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' || + str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$') + str[z1]='_'; + } + sprintf(arqtt,"%s/%s",dirname,accuser); + if(access(arqtt, R_OK) != 0) + my_mkdir(arqtt); + sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind); + if(strlen(arqtt) > 255) { + strncpy(val7,arqtt,255); + bzero(arqtt,MAXLEN); + strcpy(arqtt,val7); + } + if ((fp_tt = fopen(arqtt, "w")) == 0) { + fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt); + exit(1); + } + ttopen=1; + + if(strcmp(Privacy,"yes") == 0) + sprintf(httplink,"%s", \ + FontSize,PrivacyStringColor,PrivacyString,PrivacyString); + else + sprintf(httplink,"%s",FontSize,accurl,accurl); + + sprintf(ltext110,"%s",text[110]); + for(s=ltext110; *s; ++s) + *s=tolower(*s); + + fprintf(fp_tt, "\n\n\n \n",CharSet); + css(fp_tt); + fputs("\n",fp_tt); + fprintf(fp_tt,"\n",BgColor,TxColor,BgImage); + if(strlen(LogoImage) > 0) fprintf(fp_tt, "
%s
\n\n\n
 %s
\n",LogoImage,Width,Height,LogoText); + + if(strcmp(IndexTree,"date") == 0) + show_sarg(fp_tt, "../../../.."); + else + show_sarg(fp_tt, "../.."); + + fputs("
\n",fp_tt); + fprintf(fp_tt,"\n",Title); + + strcpy(u2,user); + if(strcmp(Ip2Name,"yes") == 0) + ip2name(u2,sizeof(u2)); + if(UserTabFile[0] != '\0') { + sprintf(warea,":%s:",u2); + if((str=(char *) strstr(userfile,warea)) != (char *) NULL ) { + z1=0; + str2=(char *) strstr(str+1,":"); + str2++; + bzero(name, MAXLEN); + while(str2[z1] != ':') { + name[z1]=str2[z1]; + z1++; + } + } else strcpy(name,u2); } else strcpy(name,u2); - } else strcpy(name,u2); - if(dotinuser && strstr(name,"_")) { - str2=(char *)subs(name,"_","."); - strcpy(name,str2); + if(dotinuser && strstr(name,"_")) { + str2=(char *)subs(name,"_","."); + strcpy(name,str2); + } + + fprintf(fp_tt,"\n",text[89],period); + fprintf(fp_tt,"\n",text[90],name); + fprintf(fp_tt,"\n",text[104],UserSortField,UserSortOrder); + fprintf(fp_tt,"\n",text[32]); + + fputs("
%s
%s: %s
%s: %s
%s: %s, %s
%s
\n",fp_tt); + fputs("
\n",fp_tt); + fputs("",fp_tt); + bzero(tmp4, MAXLEN); + strncpy(tmp4,text[110],4); + fprintf(fp_tt,"\n",text[91],tmp4,text[110]+5); } - fprintf(fp_tt,"\n",text[89],period); - fprintf(fp_tt,"\n",text[90],name); - fprintf(fp_tt,"\n",text[104],UserSortField,UserSortOrder); - fprintf(fp_tt,"\n",text[32]); - - fputs("
%s%s%s
%s: %s
%s: %s
%s: %s, %s
%s
\n",fp_tt); - fputs("
\n",fp_tt); - fputs("",fp_tt); - bzero(tmp4, MAXLEN); - strncpy(tmp4,text[110],4); - fprintf(fp_tt,"\n",text[91],tmp4,text[110]+5); - } - - sprintf(html,"\n",accurl,accdia,acchora); - - if(strcmp(html,html_old) != 0) - fputs(html,fp_tt); - strcpy(html_old, html); - } else bzero(ltext110, 50); - - strcpy(wcrc,acccode); - if (getword(crc2,sizeof(crc2),wcrc,'/')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3); - exit(1); - } + sprintf(html,"\n",accurl,accdia,acchora); - if(strstr(crc2,"MISS") != 0) - oucache+=my_atoll(accbytes); - else incache+=my_atoll(accbytes); + if(strcmp(html,html_old) != 0) + fputs(html,fp_tt); + strcpy(html_old, html); + } else bzero(ltext110, 50); - strcpy(oldurl,accurl); + strcpy(wcrc,acccode); + if (getword(crc2,sizeof(crc2),wcrc,'/')<0) { + printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3); + exit(1); + } - if(strcmp(accuser,oldaccuser) != 0) { - strcpy(wdirname,dirname); - day_totalize(tmp,oldaccuser,indexonly); - } + if(strstr(crc2,"MISS") != 0) + oucache+=my_atoll(accbytes); + else incache+=my_atoll(accbytes); - strcpy(oldaccuser,accuser); - strcpy(oldacccode,acccode); - strcpy(oldaccelap,accelap); - strcpy(oldaccip,accip); - strcpy(oldaccdia,accdia); - strcpy(oldacchora,acchora); + strcpy(oldurl,accurl); + + if(strcmp(accuser,oldaccuser) != 0) { + strcpy(wdirname,dirname); + day_totalize(tmp,oldaccuser,indexonly); + } + + strcpy(oldaccuser,accuser); + strcpy(oldacccode,acccode); + strcpy(oldaccelap,accelap); + strcpy(oldaccip,accip); + strcpy(oldaccdia,accdia); + strcpy(oldacchora,acchora); + } + bzero(user,MAXLEN); + fclose(fp_in); + unlink(tmp3); } - bzero(user,MAXLEN); - fclose(fp_in); - unlink(tmp3); -} strcpy(oldmsg,"OK"); if(strstr(oldacccode,"DENIED") != 0) @@ -380,8 +388,7 @@ void gerarel(void) return; } - -void maketmp(char *user, char *dirname, int debug, int indexonly) +static void maketmp(const char *user, const char *dirname, int debug, int indexonly) { FILE *fp_ou; @@ -411,7 +418,7 @@ void maketmp(char *user, char *dirname, int debug, int indexonly) } -void maketmp_hour(char *user, char *dirname, int indexonly) +static void maketmp_hour(const char *user, const char *dirname, int indexonly) { FILE *fp_ou; @@ -477,7 +484,7 @@ void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, } -void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly) +static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly) { FILE *fp_ou; @@ -505,7 +512,7 @@ void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap } -void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly) +static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly) { FILE *fp_ou; @@ -533,7 +540,7 @@ void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, ch } -void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache) +static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache) { FILE *fp_ou; @@ -574,7 +581,7 @@ void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc } -void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache) +static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache) { FILE *fp_ou; @@ -599,7 +606,7 @@ void gravager(char *dirname, char *user, long long int nacc, char *url, long lon } -void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart) +static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart) { FILE *fp_ou; diff --git a/siteuser.c b/siteuser.c index 8b4736f..2b33f9e 100644 --- a/siteuser.c +++ b/siteuser.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void siteuser(void) { diff --git a/smartfilter.c b/smartfilter.c index caa2e19..e9c738d 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void smartfilter_report(void) { diff --git a/sort.c b/sort.c index ce90275..844be2b 100644 --- a/sort.c +++ b/sort.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void tmpsort(void) { diff --git a/splitlog.c b/splitlog.c index aa535b7..c3cf11e 100644 --- a/splitlog.c +++ b/splitlog.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert) { diff --git a/squidguard_log.c b/squidguard_log.c index ef094e5..21c1759 100644 --- a/squidguard_log.c +++ b/squidguard_log.c @@ -24,12 +24,13 @@ */ #include "include/conf.h" +#include "include/defs.h" static char **files_done = NULL; static int nfiles_done = 0; -void read_log(char *wentp, FILE *fp_ou) +static void read_log(const char *wentp, FILE *fp_ou) { FILE *fp_in = NULL; char bufbsf[255]; @@ -168,8 +169,10 @@ void squidguard_log(void) char logdir[MAXLEN]; char year[10], day[10], mon[10]; char user[MAXLEN]; - int x, y; + int y; int cstatus; + char *str; + char *str2; str2 = user; @@ -231,46 +234,42 @@ void squidguard_log(void) fprintf(stderr, "SARG: (squidguard) %s: %s\n",text[8],SquidGuardConf); exit(1); } - + + logdir[0]=0; while(fgets(buf,sizeof(buf),fp_guard)!=NULL) { if(strstr(buf,"\n") != 0) buf[strlen(buf)-1]='\0'; - if(strstr(buf,"logdir ") != 0) { - if (getword(logdir,sizeof(logdir),buf,' ')<0 || getword(logdir,sizeof(logdir),buf,' ')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf); + if((str=get_param_value("logdir",buf))!=NULL) { + if (getword(logdir,sizeof(logdir),str,' ')<0) { + printf("SARG: Maybe you have an invalid logdir line in your %s file.\n",SquidGuardConf); exit(1); } - } - if((str=(char *) strstr(buf, "log")) != (char *) NULL ) { - str=str+3; - str2[0]='\0'; - y=0; - while(*str == ' ') - str++; - if (str == (char *) strstr(str, "anonymous")) - str+=9; + } else if((str=get_param_value("log",buf))!=NULL) { + if((str2=get_param_value("anonymous",str))!=NULL) + str=str2; - for (x=0; x<=strlen(str); x++) { - if (str[x] != ' ' && str[x] != '\t') { - str2[y] = str[x]; - y++; - } - } - if(strchr(str2,' ') != 0) { - if (getword(warea,sizeof(warea),str2,' ')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf); - exit(1); - } - strcpy(str2,warea); - } - if(strchr(str2,'#') != 0) { - if (getword(warea,sizeof(warea),str2,'#')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf); - exit(1); + /* + If logdir is defined, we prepend it to the log file name, otherwise, we assume + the log directive provides an absolute file name to the log file. Therefore, + we don't need to add an additionnal / at the beginning of the log file name. + */ + y=(logdir[0]) ? sprintf(wentp,"%s/",logdir) : 0; + /* + Spaces are allowed in the name of the log file. The file name ends at the first # + because it is assumed it is an end of line comment. Any space before the # is then + removed. Any control character (i.e. a character with a code lower than 32) ends + the file name. That includes the terminating zero. + */ + while((unsigned char)*str>=' ' && *str!='#' && y0) { + str--; + y--; } - strcpy(str2,warea); } - sprintf(wentp,"%s/%s",logdir,str2); + wentp[y]=0; read_log(wentp,fp_ou); } } diff --git a/squidguard_report.c b/squidguard_report.c index 563967f..e2cb6af 100644 --- a/squidguard_report.c +++ b/squidguard_report.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void squidguard_report(void) { diff --git a/topsites.c b/topsites.c index 3f5fc84..e90986c 100644 --- a/topsites.c +++ b/topsites.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void topsites(void) { diff --git a/topuser.c b/topuser.c index 70141f6..2936404 100644 --- a/topuser.c +++ b/topuser.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void topuser(void) { diff --git a/totday.c b/totday.c index d1caa00..15de6b0 100644 --- a/totday.c +++ b/totday.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void day_totalize(const char *tmp, const char *user, int indexonly) { diff --git a/totger.c b/totger.c index 1bcbf9c..1c0104d 100644 --- a/totger.c +++ b/totger.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" int totalger(const char *dirname, int debug, const char *outdir) { diff --git a/usage.c b/usage.c index 4ccc40d..35715a1 100644 --- a/usage.c +++ b/usage.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void usage(const char *prog) { diff --git a/useragent.c b/useragent.c index 90260a6..23c553f 100644 --- a/useragent.c +++ b/useragent.c @@ -24,6 +24,7 @@ */ #include "include/conf.h" +#include "include/defs.h" void useragent(void) { diff --git a/util.c b/util.c index 56c9feb..88869a2 100644 --- a/util.c +++ b/util.c @@ -27,6 +27,7 @@ // #define LEGACY_TESTVALIDUSERCHAR #include "include/conf.h" +#include "include/defs.h" static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; static char mtab2[12][3]={"01","02","03","04","05","06","07","08","09","10","11","12"}; @@ -1405,3 +1406,16 @@ void version(void) printf("SARG Version: %s\n",VERSION); exit(0); } + +char *get_param_value(const char *param,char *line) +{ + int plen; + + while (*line==' ' || *line=='\t') line++; + plen=strlen(param); + if (strncasecmp(line,param,plen)) return(NULL); + if (line[plen]!=' ' && line[plen]!='\t') return(NULL); + line+=plen; + while (*line==' ' || *line=='\t') line++; + return(line); +} -- 2.47.2
%s%s%s
%s%s%s
%s%s%s