]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Moved all the functions declarations from conf.h to defs.h for consistency.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 8 Jul 2009 10:01:56 +0000 (10:01 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 8 Jul 2009 10:01:56 +0000 (10:01 +0000)
Fixed bug #2089451.

41 files changed:
auth.c
authfail.c
charset.c
convlog.c
css.c
dansguardian_log.c
dansguardian_report.c
datafile.c
decomp.c
denied.c
download.c
email.c
exclude.c
getconf.c
grepday.c
html.c
include/conf.h
include/defs.h
include/info.h
index.c
indexonly.c
ip2name.c
language.c
lastlog.c
log.c
realtime.c
repday.c
report.c
siteuser.c
smartfilter.c
sort.c
splitlog.c
squidguard_log.c
squidguard_report.c
topsites.c
topuser.c
totday.c
totger.c
usage.c
useragent.c
util.c

diff --git a/auth.c b/auth.c
index 6bbf38389553c915dcd99e48edcd250384fbe642..3cb5d09bf23211a91da1aa77c8beeabedc068410 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void htaccess(const char *name)
 {
index e0a42393e069a90097c0e562528a377bf3a39c07..93c2b8f7eb6d74150aafd396e21dac89aaf4bffd 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void authfail_report(void)
 {
index 1bf02510852b54198243c0be5146e84c8e74e952..d45cca0465cf82973420cb8537a64a9148866a8a 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void ccharset(char *CharSet)
 {
index ef109435c02f948a06b12cfe8bafc9013c13c773..ccc8e6ef91230ebc1458bdd11c458b75d59a6e4c 100644 (file)
--- 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 565048c59c084a367a1ab647c92eb9807ba4cb23..ed9489362ff8ee16945128a729a2452dd8fa8324 100644 (file)
--- a/css.c
+++ b/css.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void css(FILE *fp_css)
 {
index e8876df96a4f2a1b4fd5c7b6056c3fc6f6d4fbf1..866e39302946118ceebdf8b513bb7cfcb21ebb90 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void dansguardian_log(void)
 {
index e87718000c7087eccaa5c5b0cac4b59a46c0181c..aafaec2a40dd320a79f137226b6a8eaa390f05ae 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void dansguardian_report(void)
 {
index 850230f87096049f470082f1cb82180471626f12..ea2e21fb040bf9a9db7f802ff1f5a63f32b71cfd 100644 (file)
@@ -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);
index 2f9fb719e91cdd022c3336095512f58561b58ac7..50ca8a5d9bf20bcd880d118867b8dcc1b270b6f0 100644 (file)
--- 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)
 {
index bdda37e4d43a7fe6476ec62d2b6c031232b8e78b..e45fd13e2c9a25820bc76a3b3739e07bdd899da5 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void gen_denied_report(void)
 {
index 82f61cc7c4d25600b16946485c54d893c5a8ae43..8970837750f4fec9a48c80568790194f434fe44b 100644 (file)
@@ -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 204da35ba070870d163ebdd466805d0765532ec0..ec0af2c0dfb5ac57853aed5983e4a80bb220f094 100644 (file)
--- 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)
 {
index 1d0ad4f0f02935b4fb8c9c29f1faff58fa277306..d49678fb030ef963eff697eaed773026c749a308 100644 (file)
--- 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)
 {
index a81b1e7973041f5b83981d6bedb9e726e55dc2a4..d1e0e08ce1efb0097b47f7fcfbb206d538b73a33 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 extern numlist hours, weekdays;
 
index a4b6f6d0c096805c5cba76810cbd2c02adcfc180..7ed301eec612811242b4d584d33d6007f9debd27 100644 (file)
--- 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 6a24f90d77ce6e7832816734b44b8f0a46ae4d61..71c7a89b4c9dc7f25811c8b6177211963409c802 100644 (file)
--- a/html.c
+++ b/html.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void htmlrel(void)
 {
index fa7784383e4597f6f8549521bbb761e56fb9ff64..22820b37f9296376f24c2e3e24620cd97bc12370 100755 (executable)
@@ -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);
index e1d212497bf291522fd7bf0a12c44af2de24f707..95aa6981b41112179e993cfd8c499bc8f20b4a9a 100755 (executable)
@@ -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);
index b51977c64345a7ef31d2b88ac6a430ffb2e793bd..c8cd1c9528c265824f67215dac29be9bad5c8a7b 100755 (executable)
@@ -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 60b84563a0d1ca36f7c31b35c90d9ca35197c261..22bd7cb22fbea31d181c212a675cf8baace16eac 100644 (file)
--- a/index.c
+++ b/index.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void make_index(void)
 {
index b409665ac5a0cede8d0bf872bed26afdb5041286..2f3b9c348f623ad8594367c8ade738edeb4645fc 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 
 void index_only(const char *dirname,int debug)
index 462b04592c0c99871bb7b4808e217bfcc6fd3ec0..5b0eb5ffa1c5191c84d4dae270581d91132bad44 100644 (file)
--- 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)
 { 
index 8e58a83feb98636cf357f06a49cf3cd8f325f850..625747b9cc347fd7026d5604a561bbad4b8796ca 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void language_load(const char *language)
 {
index fb48e2f14f0ac647d5ef478177851abf5a2006ec..1c9a893de4deea04566918f3564da33b8dc6a7ba 100644 (file)
--- 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 c6147c2daf35336b5274e66980a5b1f0c9190cc7..cea789269ced2bc4e47eeebe8b886cdc5e72a465 100644 (file)
--- 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
index 770d52d88e9879795da82c9406eb054cc81f6f80..ba7265350ed4c0a49fa2e1e42bd75718e3485147 100755 (executable)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 int getdata(char *, FILE *);
 void datashow(char *);
index 87b878625d6fd76e49e6192a010d1663cf8295c5..85c5543de01220c50c8309878bb4f5d025c12eb9 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 extern numlist hours;
 
index 57e10425492a16151afeca7794e06ac9497d7170..02ffdc50d9ff75d70b8fbb4c106862d01767fc79 100644 (file)
--- a/report.c
+++ b/report.c
 #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,"<font size=%s color=%s><href=http://%s>%s",   \
-                           FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
-            else
-               sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
-
-            sprintf(ltext110,"%s",text[110]);
-            for(s=ltext110; *s; ++s)
-               *s=tolower(*s);
-
-               fprintf(fp_tt, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
-            css(fp_tt);
-            fputs("</head>\n",fp_tt);
-            fprintf(fp_tt,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
-               if(strlen(LogoImage) > 0) fprintf(fp_tt, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s>&nbsp;%s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
-
-            if(strcmp(IndexTree,"date") == 0)
-               show_sarg(fp_tt, "../../../..");
-            else
-               show_sarg(fp_tt, "../..");
-
-            fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_tt);
-            fprintf(fp_tt,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\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,"<font size=%s color=%s><href=http://%s>%s",        \
+                              FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
+               else
+                  sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
+
+               sprintf(ltext110,"%s",text[110]);
+               for(s=ltext110; *s; ++s)
+                  *s=tolower(*s);
+
+               fprintf(fp_tt, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
+               css(fp_tt);
+               fputs("</head>\n",fp_tt);
+               fprintf(fp_tt,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
+               if(strlen(LogoImage) > 0) fprintf(fp_tt, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s>&nbsp;%s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
+
+               if(strcmp(IndexTree,"date") == 0)
+                  show_sarg(fp_tt, "../../../..");
+               else
+                  show_sarg(fp_tt, "../..");
+
+               fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_tt);
+               fprintf(fp_tt,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\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,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[89],period);
+               fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[90],name);
+               fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
+               fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
+
+               fputs("</table></center>\n",fp_tt);
+               fputs("<center><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
+               fputs("<tr><td></td><td></td></tr>",fp_tt);
+               bzero(tmp4, MAXLEN);
+               strncpy(tmp4,text[110],4);
+               fprintf(fp_tt,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
             }
 
-           fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[89],period);
-           fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[90],name);
-           fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
-           fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
-
-            fputs("</table></center>\n",fp_tt);
-            fputs("<center><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
-            fputs("<tr><td></td><td></td></tr>",fp_tt);
-            bzero(tmp4, MAXLEN);
-            strncpy(tmp4,text[110],4);
-            fprintf(fp_tt,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
-        }
-
-         sprintf(html,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\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,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\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;
index 8b4736fc4012bec0ca48bb5e24af785ad9595258..2b33f9ef63be6f44549cbb82a5b5a11412b72c77 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void siteuser(void)
 {
index caa2e19de3cdcc7ec74557364428d0948e58fd5c..e9c738d20edc5365afad0978685e9391c53d6ffa 100644 (file)
@@ -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 ce90275582fc805faca06086ad6a95af4fdf79c9..844be2b59c4ed769e13f5226965dfb2aed5309d8 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void tmpsort(void)
 {
index aa535b7b4a38d3fbfaadbb2a81c0795e5bd56f5d..c3cf11effc916b43474d65c6ea2e601861bee88d 100644 (file)
@@ -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)
 {
index ef094e5967ebe769d2b122ae71a422f5a14aeb62..21c1759d7c32053614622526f1ba82f970e93eea 100644 (file)
  */
 
 #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!='#' && y<sizeof(wentp)-1)
+               wentp[y++]=*str++;
+            if(*str=='#') {
+               str--;
+               while(*str==' ' && y>0) {
+                  str--;
+                  y--;
                }
-               strcpy(str2,warea);
             }
-            sprintf(wentp,"%s/%s",logdir,str2);
+            wentp[y]=0;
             read_log(wentp,fp_ou);
          }
       }
index 563967f8170ab9a968d018db7fa593b9500e6fd8..e2cb6af3f66354e7931b66f7160cd16f18460aba 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void squidguard_report(void)
 {
index 3f5fc845d152381d5480b45c4a609e2fc100b83c..e90986c470454dec3d1fe040f777e888cc4fe3b3 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void topsites(void)
 {
index 70141f6e052465119850422494e6eb1aeb586402..29364047db5a75c1222cd82cc7bd4bd1cc75f122 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void topuser(void)
 {
index d1caa0000edfcb597962419470e10b59eb13c0a1..15de6b0d70036f5bd252841d32537bda21191f3b 100644 (file)
--- 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)
 {
index 1bcbf9c5f2389e71b9fd9b3df882b09419d80007..1c0104daf1838b961566b0cf5a90bfcebdc3af93 100644 (file)
--- 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 4ccc40d740339152a7d1d9976e8eccf4e3e5b67d..35715a1c66a99ba2e9f348fcfdf8f2d789d3dcd9 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void usage(const char *prog)
 {
index 90260a633529758b33431e88199b1e6dc446bc0a..23c553fc043f81b75ec1e475f3df6505a1ced9c5 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "include/conf.h"
+#include "include/defs.h"
 
 void useragent(void)
 {
diff --git a/util.c b/util.c
index 56c9feb3eb4d64a6ed590408007bae313c80068b..88869a29a294333fe5cbf793839a166f6c7802f4 100644 (file)
--- 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);
+}