From 32e71fa45f370c385127c7abe74bef9ec110660d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Mon, 6 Jul 2009 14:21:54 +0000 Subject: [PATCH] Remove all the warnings (inspired from patch #1771501). --- authfail.c | 6 +- charset.c | 2 +- configure | 1118 +++++++++++++++++++++++++++++++++++------ configure.in | 38 +- convlog.c | 6 +- css.c | 2 +- dansguardian_log.c | 8 +- dansguardian_report.c | 9 +- datafile.c | 8 +- decomp.c | 4 +- denied.c | 6 +- download.c | 6 +- email.c | 2 +- exclude.c | 25 +- getconf.c | 2 +- grepday.c | 150 +++--- html.c | 34 +- include/conf.h | 160 +++++- index.c | 9 +- indexonly.c | 5 +- ip2name.c | 39 +- language.c | 9 +- lastlog.c | 2 +- log.c | 21 +- realtime.c | 11 +- repday.c | 2 +- report.c | 42 +- siteuser.c | 2 +- smartfilter.c | 2 +- sort.c | 114 ++--- splitlog.c | 6 +- squidguard_log.c | 4 +- squidguard_report.c | 5 +- topsites.c | 4 +- topuser.c | 10 +- totday.c | 2 +- totger.c | 3 - usage.c | 2 +- useragent.c | 2 +- util.c | 182 +++---- 40 files changed, 1503 insertions(+), 561 deletions(-) diff --git a/authfail.c b/authfail.c index 843d602..69ebbfb 100644 --- a/authfail.c +++ b/authfail.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void authfail_report() +void authfail_report(void) { FILE *fp_in = NULL, *fp_ou = NULL; @@ -78,7 +78,7 @@ void authfail_report() exit(1); } #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(authfail_in,"r"))==NULL) { + if((fp_in=fopen64(authfail_in,"r"))==NULL) { #else if((fp_in=fopen(authfail_in,"r"))==NULL) { #endif @@ -89,7 +89,7 @@ void authfail_report() unlink(tmp4); #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(report,"w"))==NULL) { + if((fp_ou=fopen64(report,"w"))==NULL) { #else if((fp_ou=fopen(report,"w"))==NULL) { #endif diff --git a/charset.c b/charset.c index d5d94ee..1bf0251 100644 --- a/charset.c +++ b/charset.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void ccharset() +void ccharset(char *CharSet) { if(strcmp(CharSet,"Latin2") == 0) strcpy(CharSet,"ISO-8859-2"); else if(strcmp(CharSet,"Latin3") == 0) strcpy(CharSet,"ISO-8859-3"); diff --git a/configure b/configure index 2830c43..86358cf 100755 --- a/configure +++ b/configure @@ -1259,6 +1259,7 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-rpath do not hardcode runtime library paths + --disable-largefile omit support for large files --enable-bindir=bindir Select bindir --enable-mandir=mandir @@ -2760,10 +2761,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu esac if test "${CC}" = "cc" ; then - CFLAGS="${CFLAGS} -w -g -O2 -Aa" + CFLAGS="${CFLAGS} -Wall -g -O2 -Aa -Werror=implicit" else - CFLAGS="${CFLAGS} -w" + CFLAGS="${CFLAGS} -Wall -Werror=implicit-function-declaration" fi +CPPFLAGS="${CFLAGS}" case "$host" in *-solaris*) @@ -5048,6 +5050,472 @@ _ACEOF fi +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; } +if test "${ac_cv_sys_largefile_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_largefile_CC=' -n32'; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; } +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_file_offset_bits=no; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_file_offset_bits=64; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -f conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; } +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_large_files=no; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_large_files=1; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -f conftest* + fi +fi + + +# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE +# needs to be defined for it +{ echo "$as_me:$LINENO: checking for fopen64" >&5 +echo $ECHO_N "checking for fopen64... $ECHO_C" >&6; } +if test "${bu_cv_have_fopen64+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen64 ("/tmp/foo","r"); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + bu_cv_have_fopen64=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + saved_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen64 ("/tmp/foo","r"); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + bu_cv_have_fopen64=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS=$saved_CPPFLAGS +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi + +{ echo "$as_me:$LINENO: result: $bu_cv_have_fopen64" >&5 +echo "${ECHO_T}$bu_cv_have_fopen64" >&6; } +if test "$bu_cv_have_fopen64" != no; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FOPEN64 1 +_ACEOF + + if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then + +cat >>confdefs.h <<\_ACEOF +#define _LARGEFILE64_SOURCE 1 +_ACEOF + + fi +fi + + { echo "$as_me:$LINENO: checking for off_t" >&5 echo $ECHO_N "checking for off_t... $ECHO_C" >&6; } if test "${ac_cv_type_off_t+set}" = set; then @@ -5059,8 +5527,435 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -typedef off_t ac__type_new_; +$ac_includes_default +typedef off_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_off_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of off_t" >&5 +echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_off_t=$ac_lo;; +'') if test "$ac_cv_type_off_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (off_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_off_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef off_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_off_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_off_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (off_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_off_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_OFF_T $ac_cv_sizeof_off_t +_ACEOF + + +if test $ac_cv_sizeof_off_t = "4"; then + +cat >>confdefs.h <<\_ACEOF +#define OFFSET_STRING "%d" +_ACEOF + +elif test $ac_cv_sizeof_off_t = "8"; then + +cat >>confdefs.h <<\_ACEOF +#define OFFSET_STRING "%lli" +_ACEOF + +else + { { echo "$as_me:$LINENO: error: can not detect the size of your system\'s off_t type" >&5 +echo "$as_me: error: can not detect the size of your system\'s off_t type" >&2;} + { (exit 1); exit 1; }; } +fi + +{ echo "$as_me:$LINENO: checking for rlim_t" >&5 +echo $ECHO_N "checking for rlim_t... $ECHO_C" >&6; } +if test "${ac_cv_type_rlim_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if HAVE_SYS_RESOURCE_H +#include +#endif + + +typedef rlim_t ac__type_new_; int main () { @@ -5089,26 +5984,26 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_cv_type_off_t=yes + ac_cv_type_rlim_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_type_off_t=no + ac_cv_type_rlim_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -echo "${ECHO_T}$ac_cv_type_off_t" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_type_rlim_t" >&5 +echo "${ECHO_T}$ac_cv_type_rlim_t" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ echo "$as_me:$LINENO: checking size of off_t" >&5 -echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; } -if test "${ac_cv_sizeof_off_t+set}" = set; then +{ echo "$as_me:$LINENO: checking size of rlim_t" >&5 +echo $ECHO_N "checking size of rlim_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_rlim_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then @@ -5119,8 +6014,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; int main () { @@ -5156,8 +6055,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; int main () { @@ -5210,8 +6113,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; int main () { @@ -5247,8 +6154,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; int main () { @@ -5311,8 +6222,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; int main () { @@ -5351,15 +6266,15 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_off_t=$ac_lo;; -'') if test "$ac_cv_type_off_t" = yes; then - { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) +?*) ac_cv_sizeof_rlim_t=$ac_lo;; +'') if test "$ac_cv_type_rlim_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (rlim_t) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t) +echo "$as_me: error: cannot compute sizeof (rlim_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else - ac_cv_sizeof_off_t=0 + ac_cv_sizeof_rlim_t=0 fi ;; esac else @@ -5369,8 +6284,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - typedef off_t ac__type_sizeof_; +#if HAVE_SYS_RESOURCE_H +#include +#endif + + + typedef rlim_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -5422,170 +6341,55 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_off_t=`cat conftest.val` + ac_cv_sizeof_rlim_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -if test "$ac_cv_type_off_t" = yes; then - { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) +if test "$ac_cv_type_rlim_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (rlim_t) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t) +echo "$as_me: error: cannot compute sizeof (rlim_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else - ac_cv_sizeof_off_t=0 + ac_cv_sizeof_rlim_t=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 -echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_rlim_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_rlim_t" >&6; } cat >>confdefs.h <<_ACEOF -#define SIZEOF_OFF_T $ac_cv_sizeof_off_t +#define SIZEOF_RLIM_T $ac_cv_sizeof_rlim_t _ACEOF -if test $ac_cv_sizeof_off_t = "4"; then +if test $ac_cv_sizeof_rlim_t = "4"; then cat >>confdefs.h <<\_ACEOF -#define OFFSET_STRING "%d" +#define RLIM_STRING "%d" _ACEOF -elif test $ac_cv_sizeof_off_t = "8"; then +elif test $ac_cv_sizeof_rlim_t = "8"; then cat >>confdefs.h <<\_ACEOF -#define OFFSET_STRING "%lli" +#define RLIM_STRING "%lli" _ACEOF else - { { echo "$as_me:$LINENO: error: can not detect the size of your system\'s off_t type" >&5 -echo "$as_me: error: can not detect the size of your system\'s off_t type" >&2;} + { { echo "$as_me:$LINENO: error: can not detect the size of your system\'s rlim_t type" >&5 +echo "$as_me: error: can not detect the size of your system\'s rlim_t type" >&2;} { (exit 1); exit 1; }; } fi -# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE -# needs to be defined for it -{ echo "$as_me:$LINENO: checking for fopen64" >&5 -echo $ECHO_N "checking for fopen64... $ECHO_C" >&6; } -if test "${bu_cv_have_fopen64+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen64 ("/tmp/foo","r"); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - bu_cv_have_fopen64=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - saved_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen64 ("/tmp/foo","r"); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - bu_cv_have_fopen64=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - CPPFLAGS=$saved_CPPFLAGS -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi - -{ echo "$as_me:$LINENO: result: $bu_cv_have_fopen64" >&5 -echo "${ECHO_T}$bu_cv_have_fopen64" >&6; } -if test "$bu_cv_have_fopen64" != no; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_FOPEN64 1 -_ACEOF - - if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then - -cat >>confdefs.h <<\_ACEOF -#define _LARGEFILE64_SOURCE 1 -_ACEOF - - fi -fi - - # Check whether --enable-bindir was given. if test "${enable_bindir+set}" = set; then enableval=$enable_bindir; diff --git a/configure.in b/configure.in index 1d74b81..74e658f 100644 --- a/configure.in +++ b/configure.in @@ -20,10 +20,11 @@ dnl * ) AC_PROG_CXX ;; esac if test "${CC}" = "cc" ; then - CFLAGS="${CFLAGS} -w -g -O2 -Aa" + CFLAGS="${CFLAGS} -Wall -g -O2 -Aa -Werror=implicit" else - CFLAGS="${CFLAGS} -w" + CFLAGS="${CFLAGS} -Wall -Werror=implicit-function-declaration" fi +CPPFLAGS="${CFLAGS}" case "$host" in *-solaris*) @@ -56,15 +57,7 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_STRUCT_TM -dnl check for the off_t size -AC_CHECK_SIZEOF(off_t) -if test $ac_cv_sizeof_off_t = "4"; then - AC_DEFINE(OFFSET_STRING, "%d", [Offset string]) -elif test $ac_cv_sizeof_off_t = "8"; then - AC_DEFINE(OFFSET_STRING, "%lli", [Offset string]) -else - AC_MSG_ERROR([can not detect the size of your system\'s off_t type]) -fi +AC_SYS_LARGEFILE # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE # needs to be defined for it @@ -87,6 +80,29 @@ if test "$bu_cv_have_fopen64" != no; then fi +dnl check for the off_t size +AC_CHECK_SIZEOF(off_t) +if test $ac_cv_sizeof_off_t = "4"; then + AC_DEFINE(OFFSET_STRING, "%d", [Offset string]) +elif test $ac_cv_sizeof_off_t = "8"; then + AC_DEFINE(OFFSET_STRING, "%lli", [Offset string]) +else + AC_MSG_ERROR([can not detect the size of your system\'s off_t type]) +fi + +dnl check for the rlim_t size +AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H +#include +#endif +]) +if test $ac_cv_sizeof_rlim_t = "4"; then + AC_DEFINE(RLIM_STRING, "%d", [Rlim string]) +elif test $ac_cv_sizeof_rlim_t = "8"; then + AC_DEFINE(RLIM_STRING, "%lli", [Rlim string]) +else + AC_MSG_ERROR([can not detect the size of your system\'s rlim_t type]) +fi + dnl Select bindir AC_ARG_ENABLE(bindir, [ --enable-bindir=bindir diff --git a/convlog.c b/convlog.c index 2c09b9e..ef10943 100644 --- a/convlog.c +++ b/convlog.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void convlog(char *arq, char *df, int dfrom, int duntil) +void convlog(const char *arq, char *df, int dfrom, int duntil) { FILE *fp_in; @@ -39,10 +39,10 @@ void convlog(char *arq, char *df, int dfrom, int duntil) struct tm *t; if(arq[0] == '\0') - strcpy(arq,"/usr/local/squid/logs/access.log"); + arq="/usr/local/squid/logs/access.log"; #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(arq,"r"))==NULL) { + if((fp_in=fopen64(arq,"r"))==NULL) { #else if((fp_in=fopen(arq,"r"))==NULL) { #endif diff --git a/css.c b/css.c index bf4e0af..565048c 100644 --- a/css.c +++ b/css.c @@ -59,7 +59,7 @@ void css(FILE *fp_css) fprintf(fp_css,".data2 a:link,a:visited {font-family:%s;color:#0000FF;font-size:%s;background-color:%s;text-decoration:none;}\n", FontFace, FontSize, TxBgColor); fprintf(fp_css,".data3 {font-family:%s;color:%s;font-size:%s;text-align:center;background-color:%s;border-right:1px solid #6A5ACD;border-bottom:1px solid #6A5ACD;}\n", FontFace, TxColor, FontSize, TxBgColor); fprintf(fp_css,".data3 a:link,a:visited {font-family:%s;color:#0000FF;font-size:%s;text-align:center;background-color:%s;text-decoration:none;}\n", FontFace, FontSize, TxBgColor); - fprintf(fp_css,".text {font-family:%s;color:%s;font-size:%s;text-align:right;}\n", FontFace, TxColor, FontSize, TxBgColor); + fprintf(fp_css,".text {font-family:%s;color:%s;font-size:%s;background-color:%s;text-align:right;}\n", FontFace, TxColor, FontSize, TxBgColor); fprintf(fp_css,".link {font-family:%s;font-size:%s;color:#0000FF;}\n", FontFace, FontSize); fprintf(fp_css,".link a:link,a:visited {font-family:%s;font-size:%s;color:#0000FF;text-decoration:none;}\n\n", FontFace, FontSize); } diff --git a/dansguardian_log.c b/dansguardian_log.c index af73f95..3588d43 100644 --- a/dansguardian_log.c +++ b/dansguardian_log.c @@ -25,7 +25,7 @@ #include "include/conf.h" -int dansguardian_log() +void dansguardian_log(void) { FILE *fp_in = NULL, *fp_ou = NULL, *fp_guard = NULL; @@ -38,7 +38,6 @@ int dansguardian_log() char ip[30]; char wdata[127]; int idata=0; - int x, y; int cstatus; bzero(day, 3); @@ -88,7 +87,7 @@ int dansguardian_log() } #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(guard_in,"a"))==NULL) { + if((fp_ou=fopen64(guard_in,"a"))==NULL) { #else if((fp_ou=fopen(guard_in,"a"))==NULL) { #endif @@ -121,7 +120,7 @@ int dansguardian_log() } #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(loglocation,"r"))==NULL) { + if((fp_in=fopen64(loglocation,"r"))==NULL) { #else if((fp_in=fopen(loglocation,"r"))==NULL) { #endif @@ -175,5 +174,4 @@ int dansguardian_log() exit(1); } unlink(guard_in); - return; } diff --git a/dansguardian_report.c b/dansguardian_report.c index b87c662..1ae3f3f 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -25,16 +25,14 @@ #include "include/conf.h" -void dansguardian_report() +void dansguardian_report(void) { FILE *fp_in = NULL, *fp_ou = NULL; char url[MAXLEN]; - char html[MAXLEN]; char html2[MAXLEN]; char dansguardian_in[MAXLEN]; - char dansguardian_ou[MAXLEN]; char per[MAXLEN]; char report[MAXLEN]; char period[100]; @@ -46,7 +44,6 @@ void dansguardian_report() char date[15]; char date2[15]; char hour[15]; - char ftime[128]; char *str; int z=0; int count=0; @@ -71,7 +68,7 @@ void dansguardian_report() fclose(fp_in); #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(dansguardian_in,"r"))==NULL) { + if((fp_in=fopen64(dansguardian_in,"r"))==NULL) { #else if((fp_in=fopen(dansguardian_in,"r"))==NULL) { #endif @@ -80,7 +77,7 @@ void dansguardian_report() } #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(report,"w"))==NULL) { + if((fp_ou=fopen64(report,"w"))==NULL) { #else if((fp_ou=fopen(report,"w"))==NULL) { #endif diff --git a/datafile.c b/datafile.c index c94ec40..850230f 100644 --- a/datafile.c +++ b/datafile.c @@ -66,7 +66,7 @@ void data_file(char *tmp) sprintf(tmp3,"%s/%s",tmp,direntp->d_name); #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(tmp3,"r"))==NULL){ + if((fp_in=fopen64(tmp3,"r"))==NULL){ #else if((fp_in=fopen(tmp3,"r"))==NULL){ #endif @@ -74,7 +74,6 @@ void data_file(char *tmp) exit(1); } strcpy(wdname,direntp->d_name); - strip_prefix: if (getword(wname2,sizeof(wname2),wdname,'.')<0) { printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",tmp); exit(1); @@ -161,16 +160,15 @@ void data_file(char *tmp) 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) { - FILE *fp_ou; char reg[MAXLEN]; #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(DataFile,"a"))==NULL){ + if((fp_ou=fopen64(DataFile,"a"))==NULL){ #else if((fp_ou=fopen(DataFile,"a"))==NULL){ #endif - fprintf(stderr, "SARG: (datafile) %s: %s\n",text[45],DataFile); + fprintf(stderr, "SARG: (datafile) %s: %s\n",text[45],DataFile); exit(1); } diff --git a/decomp.c b/decomp.c index 3a3be2e..2f9fb71 100644 --- a/decomp.c +++ b/decomp.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void decomp(char *arq, char *zip, char *tmp) +void decomp(char *arq, char *zip, const char *tmp) { char cmd[1024]; int cstatus; @@ -85,7 +85,7 @@ void decomp(char *arq, char *zip, char *tmp) } -void recomp(char *arq, char *zip) +void recomp(const char *arq, const char *zip) { char cmd[1024]; int cstatus; diff --git a/denied.c b/denied.c index 21f20dd..66bc392 100644 --- a/denied.c +++ b/denied.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void gen_denied_report() +void gen_denied_report(void) { FILE *fp_in = NULL, *fp_ou = NULL; @@ -67,7 +67,7 @@ void gen_denied_report() fclose(fp_in); #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(denied_in,"r"))==NULL) { + if((fp_in=fopen64(denied_in,"r"))==NULL) { #else if((fp_in=fopen(denied_in,"r"))==NULL) { #endif @@ -76,7 +76,7 @@ void gen_denied_report() } #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(report,"w"))==NULL) { + if((fp_ou=fopen64(report,"w"))==NULL) { #else if((fp_ou=fopen(report,"w"))==NULL) { #endif diff --git a/download.c b/download.c index bb3c56a..ee47d79 100644 --- a/download.c +++ b/download.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void download_report() +void download_report(void) { FILE *fp_in = NULL, *fp_ou = NULL; @@ -68,7 +68,7 @@ void download_report() fclose(fp_in); #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(report_in,"r"))==NULL) { + if((fp_in=fopen64(report_in,"r"))==NULL) { #else if((fp_in=fopen(report_in,"r"))==NULL) { #endif @@ -77,7 +77,7 @@ void download_report() } #if defined(HAVE_FOPEN64) - if((fp_ou=(long)fopen64(report,"w"))==NULL) { + if((fp_ou=fopen64(report,"w"))==NULL) { #else if((fp_ou=fopen(report,"w"))==NULL) { #endif diff --git a/email.c b/email.c index 8974ad3..fafabe1 100644 --- a/email.c +++ b/email.c @@ -25,7 +25,7 @@ #include "include/conf.h" -int geramail(const char *dirname, int debug, const char *outdir, int userip, char *email, char *TempDir) +int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir) { FILE *fp_in, *fp_top1, *fp_top2, *fp_top3; diff --git a/exclude.c b/exclude.c index f4a1840..1d0ad4f 100644 --- a/exclude.c +++ b/exclude.c @@ -25,7 +25,7 @@ #include "include/conf.h" -int vhexclude(char *excludefile, char *url) +int vhexclude(const char *excludefile, const char *url) { char whost[1024]; @@ -34,12 +34,12 @@ int vhexclude(char *excludefile, char *url) int len = strlen(excludefile); if((str=(char *) malloc(len+1))==NULL) { - fprintf(stderr, "SARG: %s (%ld):\n",text[59], len); + fprintf(stderr, "SARG: %s (%d):\n",text[59], len); exit(1); } len = strlen(url); if((wurl=(char *) malloc(len+1))==NULL) { - fprintf(stderr, "SARG: %s (%ld):\n",text[59], len); + fprintf(stderr, "SARG: %s (%d):\n",text[59], len); exit(1); } whost[0]='\0'; @@ -90,16 +90,17 @@ int vhexclude(char *excludefile, char *url) } -int vuexclude(char *excludeuser, char *user) +int vuexclude(const char *excludeuser, const char *user) { + const char *wuser; + int len; - char wuser[MAXLEN]; - - strcpy(wuser,user); - strcat(wuser," "); - - if(strstr(excludeuser,wuser) != 0 ) - return(0); - + len=strlen(user); + wuser=excludeuser; + while ((wuser=strstr(wuser,user))!=NULL) { + if (wuser[len]==' ') return(0); + wuser+=len; + } + return(1); } diff --git a/getconf.c b/getconf.c index 86f242e..a81b1e7 100644 --- a/getconf.c +++ b/getconf.c @@ -1089,7 +1089,7 @@ void parmtest(char *buf) } } -void getconf() +void getconf(void) { FILE *fp_in; diff --git a/grepday.c b/grepday.c index 2b2153b..a4b6f6d 100644 --- a/grepday.c +++ b/grepday.c @@ -71,76 +71,76 @@ char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist, #define SARGgdImageStringFT gdImageStringFT #endif -void *bar(long long int *n) +void bar(long long int n) { #ifdef HAVE_GD gdPoint points[4]; int brect[8]; int val=0, x; - long long int lim, num; + long long int num; char v[15]; - static char limits[400][12]={"0","500","1000","2000","3000","4000", - "5000","6000","7000","8000","9000","10000", - "20000","30000","40000","50000","70000","90000", - "110000","130000","150000","170000","190000","210000", - "230000","250000","280000","310000","340000","370000", - "400000","430000","450000","460000","490000","500000", - "550000","600000","650000","700000","750000","800000", - "850000","900000","950000","1000000","1100000","1200000", - "1300000","1400000","1500000","1600000","1700000","1800000", - "1900000","2000000","2100000","2200000","2300000","2400000", - "2500000","2600000","2700000","2800000","2900000","3000000", - "3100000","3200000","3300000","3400000","3500000","3600000", - "3700000","3800000","3900000","4000000","4100000","4200000", - "4300000","4400000","4500000","4600000","4700000","4800000", - "4900000","5000000","5100000","5200000","5300000","5400000", - "5500000","5600000","5700000","5800000","5900000","6000000", - "6100000","6200000","6300000","6400000","6500000","6600000", - "6700000","6800000","6900000","7000000","7100000","7200000", - "7300000","7400000","7500000","7600000","7700000","7800000", - "7900000","8000000","8100000","8200000","8300000","8400000", - "8500000","8600000","8700000","8800000","8900000","9000000", - "9100000","9200000","9300000","9400000","9500000","9600000", - "9700000","9800000","9900000","10000000","10500000","11000000", - "11500000","12000000","12500000","13000000","13500000","14000000", - "14500000","15000000","15500000","16000000","16500000","17000000", - "17500000","18000000","18500000","19000000","19500000","20000000", - "21000000","22000000","23000000","24000000","25000000","26000000", - "27000000","28000000","29000000","30000000","31000000","32000000", - "33000000","34000000","35000000","36000000","37000000","38000000", - "39000000","40000000","41000000","42000000","43000000","44000000", - "45000000","46000000","47000000","48000000","49000000","50000000", - "51000000","52000000","53000000","54000000","55000000","56000000", - "57000000","58000000","59000000","60000000","61000000","62000000", - "63000000","64000000","65000000","66000000","67000000","68000000", - "69000000","70000000","71000000","72000000","73000000","74000000", - "75000000","76000000","77000000","78000000","79000000","80000000", - "81000000","82000000","83000000","84000000","85000000","86000000", - "87000000","88000000","89000000","90000000","91000000","92000000", - "93000000","94000000","95000000","96000000","97000000","98000000", - "99000000","100000000","110000000","120000000","130000000","140000000", - "150000000","160000000","170000000","180000000","190000000","200000000", - "210000000","220000000","230000000","240000000","250000000","260000000", - "270000000","280000000","290000000","300000000","310000000","320000000", - "330000000","340000000","350000000","360000000","370000000","380000000", - "390000000","400000000","410000000","420000000","430000000","440000000", - "450000000","460000000","470000000","480000000","490000000","500000000", - "510000000","520000000","530000000","540000000","550000000","560000000", - "570000000","580000000","590000000","600000000","610000000","620000000", - "630000000","640000000","650000000","660000000","670000000","680000000", - "690000000","700000000","710000000","720000000","730000000","740000000", - "750000000","760000000","770000000","780000000","790000000","800000000", - "810000000","820000000","830000000","840000000","850000000","860000000", - "870000000","880000000","890000000","900000000","910000000","920000000", - "930000000","940000000","950000000","960000000","970000000","980000000", - "990000000","1000000000","1100000000","1200000000","1300000000","1400000000", - "1500000000","1600000000","1700000000","1800000000","1900000000","2000000000", - "2100000000","2200000000","2300000000","2400000000","2500000000","2600000000", - "2700000000","2800000000","2900000000","3000000000","3100000000","3200000000", - "3300000000","3400000000","3500000000","3600000000","3700000000","3800000000", - "3900000000","4000000000","4100000000","4200000000","4300000000","4400000000", - "4500000000","4600000000","4700000000","4800000000","4900000000","5000000000"}; + static const long long int limits[400]={0,500,1000,2000,3000,4000, + 5000,6000,7000,8000,9000,10000, + 20000,30000,40000,50000,70000,90000, + 110000,130000,150000,170000,190000,210000, + 230000,250000,280000,310000,340000,370000, + 400000,430000,450000,460000,490000,500000, + 550000,600000,650000,700000,750000,800000, + 850000,900000,950000,1000000,1100000,1200000, + 1300000,1400000,1500000,1600000,1700000,1800000, + 1900000,2000000,2100000,2200000,2300000,2400000, + 2500000,2600000,2700000,2800000,2900000,3000000, + 3100000,3200000,3300000,3400000,3500000,3600000, + 3700000,3800000,3900000,4000000,4100000,4200000, + 4300000,4400000,4500000,4600000,4700000,4800000, + 4900000,5000000,5100000,5200000,5300000,5400000, + 5500000,5600000,5700000,5800000,5900000,6000000, + 6100000,6200000,6300000,6400000,6500000,6600000, + 6700000,6800000,6900000,7000000,7100000,7200000, + 7300000,7400000,7500000,7600000,7700000,7800000, + 7900000,8000000,8100000,8200000,8300000,8400000, + 8500000,8600000,8700000,8800000,8900000,9000000, + 9100000,9200000,9300000,9400000,9500000,9600000, + 9700000,9800000,9900000,10000000,10500000,11000000, + 11500000,12000000,12500000,13000000,13500000,14000000, + 14500000,15000000,15500000,16000000,16500000,17000000, + 17500000,18000000,18500000,19000000,19500000,20000000, + 21000000,22000000,23000000,24000000,25000000,26000000, + 27000000,28000000,29000000,30000000,31000000,32000000, + 33000000,34000000,35000000,36000000,37000000,38000000, + 39000000,40000000,41000000,42000000,43000000,44000000, + 45000000,46000000,47000000,48000000,49000000,50000000, + 51000000,52000000,53000000,54000000,55000000,56000000, + 57000000,58000000,59000000,60000000,61000000,62000000, + 63000000,64000000,65000000,66000000,67000000,68000000, + 69000000,70000000,71000000,72000000,73000000,74000000, + 75000000,76000000,77000000,78000000,79000000,80000000, + 81000000,82000000,83000000,84000000,85000000,86000000, + 87000000,88000000,89000000,90000000,91000000,92000000, + 93000000,94000000,95000000,96000000,97000000,98000000, + 99000000,100000000,110000000,120000000,130000000,140000000, + 150000000,160000000,170000000,180000000,190000000,200000000, + 210000000,220000000,230000000,240000000,250000000,260000000, + 270000000,280000000,290000000,300000000,310000000,320000000, + 330000000,340000000,350000000,360000000,370000000,380000000, + 390000000,400000000,410000000,420000000,430000000,440000000, + 450000000,460000000,470000000,480000000,490000000,500000000, + 510000000,520000000,530000000,540000000,550000000,560000000, + 570000000,580000000,590000000,600000000,610000000,620000000, + 630000000,640000000,650000000,660000000,670000000,680000000, + 690000000,700000000,710000000,720000000,730000000,740000000, + 750000000,760000000,770000000,780000000,790000000,800000000, + 810000000,820000000,830000000,840000000,850000000,860000000, + 870000000,880000000,890000000,900000000,910000000,920000000, + 930000000,940000000,950000000,960000000,970000000,980000000, + 990000000LL,1000000000LL,1100000000LL,1200000000LL,1300000000LL,1400000000LL, + 1500000000LL,1600000000LL,1700000000LL,1800000000LL,1900000000LL,2000000000LL, + 2100000000LL,2200000000LL,2300000000LL,2400000000LL,2500000000LL,2600000000LL, + 2700000000LL,2800000000LL,2900000000LL,3000000000LL,3100000000LL,3200000000LL, + 3300000000LL,3400000000LL,3500000000LL,3600000000LL,3700000000LL,3800000000LL, + 3900000000LL,4000000000LL,4100000000LL,4200000000LL,4300000000LL,4400000000LL, + 4500000000LL,4600000000LL,4700000000LL,4800000000LL,4900000000LL,5000000000LL}; if(access(font1, R_OK) != 0) { fprintf(stderr, "SARG: (grepday) Fontname: %s not found.\n",font1); @@ -185,14 +185,13 @@ void *bar(long long int *n) goldenrod2 = gdImageColorAllocate(im, 207, 181, 59); num = n; + val = 55; for(x=0; x<=366; x++) { - lim = my_atoll(limits[x]); - if(lim >= num) { + if(limits[x] >= num) { val = 425 - x; break; } } - if(x>366) val = 55; gdImageFilledRectangle(im, x1, val, x1+11, 425, color3); @@ -228,7 +227,7 @@ void *bar(long long int *n) return; } -void greport_day(char *user, int *iprel, int *ipuser) +void greport_day(const char *user) { FILE *fp_in, *pngout; int x, y; @@ -242,7 +241,7 @@ void greport_day(char *user, int *iprel, int *ipuser) char oday[20]; char day[20]; char bytes[20]; - long long int tot; + long long int tot=0; time_t t; struct tm *local; int cstatus; @@ -372,9 +371,18 @@ void greport_day(char *user, int *iprel, int *ipuser) SARGgdImageStringFT(im,&brect[0],black,font1,10,3.14/2,20,248,text[93]); SARGgdImageStringFT(im,&brect[0],black,font1,10,0.0,330,460,text[127]); - sprintf(graph,"%s/%s/graph_day.png",dirname,user); - sprintf(wdirname,"%s/%s.day",tmp,user); - sprintf(tmp5,"%s/%s.graph",tmp,user); + if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",dirname,user)>=sizeof(graph)) { + fprintf(stderr, "SARG: user name too long for: %s/%s/graph_day.png\n",dirname,user); + exit(1); + } + if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,user)>=sizeof(wdirname)) { + fprintf(stderr, "SARG: user name too long for: %s/%s.day\n",tmp,user); + exit(1); + } + if (snprintf(tmp5,sizeof(tmp5),"%s/%s.graph",tmp,user)>=sizeof(tmp5)) { + fprintf(stderr, "SARG: user name too long for: %s/%s.graph\n",tmp,user); + exit(1); + } if(access(wdirname, R_OK) != 0) return; diff --git a/html.c b/html.c index 70b8c2d..2e684fa 100644 --- a/html.c +++ b/html.c @@ -25,29 +25,29 @@ #include "include/conf.h" -void htmlrel() +void htmlrel(void) { DIR *dirp; - FILE *fp_in, *fp_ou, *fp_ip, *fp_ip2, *fp_usr, *fp_tt; + FILE *fp_in, *fp_ou, *fp_ip, *fp_ip2, *fp_usr; struct dirent *direntp; long long int nnbytes=0, unbytes=0, tnbytes=0, totbytes=0, totbytes2=0; long long int totelap=0, totelap2=0, nnelap=0, unelap=0, tnelap=0; long long int incache=0, oucache=0, tnincache=0, tnoucache=0, twork=0, twork2=0; char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN]; - char nacc[20], nbytes[20], url[1024], purl[1024], tmsg[50], tmsg2[50], nelap[20], csort[MAXLEN]; + char nacc[20], nbytes[20], url[1024], tmsg[50], nelap[20], csort[MAXLEN]; char period[MAXLEN], usuario[MAXLEN], wusuario[MAXLEN], u2[MAXLEN], duser[MAXLEN]; char userbytes[20], userelap[20], userurl[1024], userhora[9], userdia[9]; char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN], incac[20], oucac[20]; char denied_report[255], name2[MAXLEN]; - char ttd1[3], ttd2[3], ttd3[5], ttt1[3], ttt2[3], ttt3[3]; + //char ttd1[3], ttd2[3], ttd3[5], ttt1[3], ttt2[3], ttt3[3]; char *str; - char ftime[128], warea[MAXLEN]; + char warea[MAXLEN]; char wtemp[MAXLEN], totuser[8]; long long int tnacc=0, ttnacc=0, unacc=0; float perc=0, perc2=0, ouperc=0, inperc=0; char *s; - int x, count; + int count; int cstatus; if(strstr(ReportType,"users_sites") == 0) return; @@ -126,8 +126,8 @@ void htmlrel() sprintf(warea,"%s/%s",dirname,wusuario); mkdir(warea,0755); - report_day(wusuario, iprel, userip); - greport_day(wusuario, iprel, userip); + report_day(wusuario); + greport_day(wusuario); strcpy(usuario,wusuario); strcpy(arqin,tmp); @@ -356,9 +356,9 @@ void htmlrel() } else ouperc=0; twork=my_atoll(nacc); - sprintf(wwork1,"%s",fixnum(twork,1)); - sprintf(wwork2,"%s",fixnum(nnbytes,1)); - sprintf(wwork3,"%s",fixnum2(nnelap,1)); + strcpy(wwork1,fixnum(twork,1)); + strcpy(wwork2,fixnum(nnbytes,1)); + strcpy(wwork3,fixnum2(nnelap,1)); if(strcmp(LongUrl,"yes") != 0) { if (getword(warea,sizeof(warea),url,'/')<0) { @@ -390,11 +390,9 @@ void htmlrel() sprintf(httplink,"%s",urly,urly,url); if(strstr(ReportType,"site_user_time_date") != 0) { - sprintf(ltext110,"%s",text[110]); - if(ltext110){ - for(s=ltext110; *s; ++s) - *s=tolower(*s); - } + strcpy(ltext110,text[110]); + for(s=ltext110; *s; ++s) + *s=tolower(*s); strcpy(siteind,urly); str=siteind; for(z1=0; str[z1]; z1++) { @@ -469,7 +467,7 @@ void htmlrel() } #if defined(HAVE_FOPEN64) - if ((fp_ip2 = (long)fopen64(tmp2, "a")) == 0){ + if ((fp_ip2 = fopen64(tmp2, "a")) == 0){ #else if ((fp_ip2 = fopen(tmp2, "a")) == 0){ #endif @@ -494,7 +492,7 @@ void htmlrel() } #if defined(HAVE_FOPEN64) - if ((fp_ip = (long)fopen64(tmp3, "r")) == 0) { + if ((fp_ip = fopen64(tmp3, "r")) == 0) { #else if ((fp_ip = fopen(tmp3, "r")) == 0) { #endif diff --git a/include/conf.h b/include/conf.h index faae954..fa77843 100755 --- a/include/conf.h +++ b/include/conf.h @@ -122,9 +122,6 @@ char href3[MAXLEN]; char df[20]; char day[3], month[4], year[5]; char nmonth[30]; -char y1[5], y2[5]; -char d1[3], d2[3]; -char m1[4], m2[4]; char ltext110[50]; char cdfrom[30]; char cduntil[30]; @@ -346,11 +343,160 @@ typedef struct DIR *dirp; struct dirent *direntp; -int getnumlist( char *, numlist *, const int, const int ); +// 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 ip2name(char *ip,int ip_len); - - \ No newline at end of file +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/index.c b/index.c index d9fd7b8..60b8456 100644 --- a/index.c +++ b/index.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void make_index() +void make_index(void) { FILE *fp_ou, *fp_ou2, *fp_ou3, *fp_tmp, *fp_tmp2, *fp_tmp3; @@ -49,8 +49,11 @@ void make_index() char day[4], mon[4], year[6], hour[10]; char h[3], m[3], s[3]; int cstatus; + char y1[5], y2[5]; + char d1[3], d2[3]; + char m1[4], m2[4]; - if(LastLog[0] != '\0') mklastlog(outdir,debug); + if(LastLog[0] != '\0') mklastlog(outdir); sprintf(wdir,"%sindex.html",outdir); sprintf(wdir_tmp,"%sindex.unsort",outdir); @@ -181,7 +184,7 @@ void make_index() while ((direntp = readdir( dirp )) != NULL) { char *p; if(strcmp(IndexTree,"date") == 0) { - if(strlen(direntp->d_name) > 4 || !isdigit(direntp->d_name[0]) && !isdigit(direntp->d_name[1])) continue; + if(strlen(direntp->d_name) > 4 || (!isdigit(direntp->d_name[0]) && !isdigit(direntp->d_name[1]))) continue; fprintf(fp_tmp,"%s %s\n",direntp->d_name,get_size(outdir,direntp->d_name)); continue; } else { diff --git a/indexonly.c b/indexonly.c index 507392d..b409665 100644 --- a/indexonly.c +++ b/indexonly.c @@ -26,14 +26,12 @@ #include "include/conf.h" -void index_only() +void index_only(const char *dirname,int debug) { - DIR *dirp; struct dirent *direntp; char remove[MAXLEN]; - dirp = opendir(dirname); while ( (direntp = readdir( dirp )) != NULL ){ if(strcmp(direntp->d_name,".") == 0 || strcmp(direntp->d_name,"..") == 0 || strcmp(direntp->d_name, "index.html") == 0) @@ -43,7 +41,6 @@ void index_only() unlink(remove); } - (void)rewinddir( dirp ); (void)closedir( dirp ); return; diff --git a/ip2name.c b/ip2name.c index 1907130..462b045 100644 --- a/ip2name.c +++ b/ip2name.c @@ -53,34 +53,27 @@ void name2ip(char *name) { struct in_addr ia; struct hostent *hp; - char work[MAXLEN]; - char n1[4]; - char n2[4]; - char n3[4]; - char n4[4]; + char *port; + char n1[4]; + char n2[4]; + char n3[4]; + char n4[4]; - if(strstr(name,":") > 0) { - if (getword(work,sizeof(work),name,':')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s name.\n",name); - exit(1); - } - strcpy(name,work); - } + port=strchr(name,':'); + if (port) *port=0; if((hp=gethostbyname(name))==NULL) return; - else { - memcpy(&ia.s_addr,hp->h_addr_list[0],sizeof(ia.s_addr)); - ia.s_addr=ntohl(ia.s_addr); - sprintf(name,"%s",inet_ntoa(ia)); - if (getword(n4,sizeof(n4),name,'.')<0 || getword(n3,sizeof(n3),name,'.')<0 || - getword(n2,sizeof(n2),name,'.')<0 || getword(n1,sizeof(n1),name,0)<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s ip address.\n",name); - exit(1); - } - sprintf(name,"%s.%s.%s.%s",n1,n2,n3,n4); - + + memcpy(&ia.s_addr,hp->h_addr_list[0],sizeof(ia.s_addr)); + ia.s_addr=ntohl(ia.s_addr); + strcpy(name,inet_ntoa(ia)); + if (getword(n4,sizeof(n4),name,'.')<0 || getword(n3,sizeof(n3),name,'.')<0 || + getword(n2,sizeof(n2),name,'.')<0 || getword(n1,sizeof(n1),name,0)<0) { + printf("SARG: Maybe you have a broken record or garbage in your %s ip address.\n",name); + exit(1); } + sprintf(name,"%s.%s.%s.%s",n1,n2,n3,n4); return; } diff --git a/language.c b/language.c index fbae8cc..8e58a83 100644 --- a/language.c +++ b/language.c @@ -25,13 +25,16 @@ #include "include/conf.h" -void language_load(char *language) +void language_load(const char *language) { char lfile[FILENAME_MAX]; FILE *fp_text; int record=0; - sprintf(lfile,"%s/languages/%s",SYSCONFDIR,language); + if (snprintf(lfile,sizeof(lfile),"%s/languages/%s",SYSCONFDIR,language)>=sizeof(lfile)) { + fprintf(stderr, "SARG: (language) language name is too long: %s/languages/%s\n",SYSCONFDIR,language); + exit(1); + } if((fp_text=fopen(lfile,"r"))==NULL) { fprintf(stderr, "SARG: (language) Cannot open language file: %s\n",lfile); @@ -46,7 +49,7 @@ void language_load(char *language) strcpy(text[record],warea); if(langcode) - printf("%d %s\n",record,warea); + printf("%d %s\n",record,warea); record++; } diff --git a/lastlog.c b/lastlog.c index 19a0c81..abbaca4 100644 --- a/lastlog.c +++ b/lastlog.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void mklastlog() +void mklastlog(const char *outdir) { FILE *fp_in, *fp_ou; diff --git a/log.c b/log.c index beb8bbf..7c0b0c0 100644 --- a/log.c +++ b/log.c @@ -54,7 +54,7 @@ int main(argc,argv) char *argv[]; { - FILE *fp_in = NULL, *fp_ou = NULL, *fp_denied, *fp_usr, *fp_authfail, *fp_log; + FILE *fp_in = NULL, *fp_ou = NULL, *fp_denied=NULL, *fp_usr, *fp_authfail=NULL, *fp_log=NULL; char sz_Download_Unsort[ 20000 ] ; FILE * fp_Download_Unsort = NULL ; @@ -679,7 +679,7 @@ int main(argc,argv) } if(debug) { - sprintf(msg,"Maximum file descriptor: cur=%ld max=%ld, changed to cur=%ld max=%ld",l1,l2,rl.rlim_cur,rl.rlim_max); + sprintf(msg,"Maximum file descriptor: cur=%ld max=%ld, changed to cur="RLIM_STRING" max="RLIM_STRING,l1,l2,rl.rlim_cur,rl.rlim_max); debuga(msg); } } @@ -739,7 +739,7 @@ int main(argc,argv) } #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(arq,"r"))==NULL) { + if((fp_in=fopen64(arq,"r"))==NULL) { #else if((fp_in=fopen(arq,"r"))==NULL) { #endif @@ -766,7 +766,7 @@ int main(argc,argv) } sprintf(arq_log,"%s/sarg_temp.log",ParsedOutputLog); #if defined(HAVE_FOPEN64) - if((fp_log=(long)fopen64(arq_log,"w"))==NULL) { + if((fp_log=fopen64(arq_log,"w"))==NULL) { #else if((fp_log=fopen(arq_log,"w"))==NULL) { #endif @@ -778,7 +778,7 @@ int main(argc,argv) if(strstr(ReportType,"denied") != 0) { #if defined(HAVE_FOPEN64) - if((fp_denied=(long)fopen64(tmp4,"w"))==NULL) { + if((fp_denied=fopen64(tmp4,"w"))==NULL) { #else if((fp_denied=fopen(tmp4,"w"))==NULL) { #endif @@ -790,7 +790,7 @@ int main(argc,argv) if(DataFile[0]=='\0') { if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) { #if defined(HAVE_FOPEN64) - if((fp_authfail=(long)fopen64(tmp6,"w"))==NULL) { + if((fp_authfail=fopen64(tmp6,"w"))==NULL) { #else if((fp_authfail=fopen(tmp6,"w"))==NULL) { #endif @@ -1412,7 +1412,7 @@ int main(argc,argv) if(download_flag && strstr(code,"DENIED") == 0) { ndownload = 1; - sprintf(bufz, "%s %s %s %s %s %s\n",dia,hora,user,ip,download_url); + sprintf(bufz, "%s %s %s %s %s\n",dia,hora,user,ip,download_url); #ifdef LEGACY_WRITE_DOWNLOAD sprintf(tmp3,"%s/sarg/download.unsort",tmp); @@ -1520,10 +1520,8 @@ int main(argc,argv) fclose(fp_denied); if(fp_authfail) fclose(fp_authfail); - if(tmp4) - unlink(tmp4); - if(tmp6) - unlink(tmp6); + unlink(tmp4); + unlink(tmp6); unlink(tmp3); exit(0); } @@ -1608,7 +1606,6 @@ int main(argc,argv) sort_users_log(tmp, debug); - report_gen: if(strlen(DataFile) > 0) data_file(tmp); else diff --git a/realtime.c b/realtime.c index 6b71f5f..deb9eaf 100755 --- a/realtime.c +++ b/realtime.c @@ -27,8 +27,8 @@ int getdata(char *, FILE *); void datashow(char *); -void getlog(); -void header(); +static void getlog(void); +static void header(void); char dat[128]; char tim[128]; @@ -36,15 +36,14 @@ char typ[128]; char ouser[MAXLEN]=""; char ourl[MAXLEN]=""; -void -realtime(int argc, char *argv[]) +void realtime(void) { getlog(); } -void getlog() +static void getlog(void) { FILE *tmp, *fp, *fp_usr; char template1[255]="/var/tmp/sargtpl1.XXXXXX"; @@ -269,7 +268,7 @@ void datashow(char *tmp) } -void header() +static void header(void) { puts("\n"); diff --git a/repday.c b/repday.c index aa0bafc..db4ec0c 100644 --- a/repday.c +++ b/repday.c @@ -27,7 +27,7 @@ extern numlist hours; -void report_day(char *user, int *iprel, int *ipuser) +void report_day(const char *user) { FILE *fp_in, *fp_ou; diff --git a/report.c b/report.c index 10d790d..58a6a94 100644 --- a/report.c +++ b/report.c @@ -26,7 +26,7 @@ #include "include/conf.h" #include "include/defs.h" -void gerarel() +void gerarel(void) { FILE *fp_in; @@ -191,45 +191,43 @@ void gerarel() 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) + 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); + 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; + ttopen=1; - if(strcmp(Privacy,"yes") == 0) + if(strcmp(Privacy,"yes") == 0) sprintf(httplink,"%s", \ - FontSize,PrivacyStringColor,PrivacyString,PrivacyString); - else + FontSize,PrivacyStringColor,PrivacyString,PrivacyString); + else sprintf(httplink,"%s",FontSize,accurl,accurl); sprintf(ltext110,"%s",text[110]); - if(ltext110){ - for(s=ltext110; *s; ++s) - *s=tolower(*s); - } + for(s=ltext110; *s; ++s) + *s=tolower(*s); - fprintf(fp_tt, "\n\n\n \n",CharSet); + 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(strlen(LogoImage) > 0) fprintf(fp_tt, "
\n\n\n
 %s
\n",LogoImage,Width,Height,LogoText); if(strcmp(IndexTree,"date") == 0) show_sarg(fp_tt, "../../../.."); diff --git a/siteuser.c b/siteuser.c index 261644a..7adb880 100644 --- a/siteuser.c +++ b/siteuser.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void siteuser() +void siteuser(void) { FILE *fp_in, *fp_ou; diff --git a/smartfilter.c b/smartfilter.c index c214db4..8e73063 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void smartfilter_report() +void smartfilter_report(void) { FILE *fp_in = NULL, *fp_ou = NULL, *fp_user = NULL; diff --git a/sort.c b/sort.c index ec2a838..ce90275 100644 --- a/sort.c +++ b/sort.c @@ -25,15 +25,17 @@ #include "include/conf.h" -void tmpsort() +void tmpsort(void) { DIR *dirp; struct dirent *direntp; int cstatus; + const char tmpext[]=".utmp"; + int dlen; char csort[MAXLEN]; - char arqou[MAXLEN], arqin[MAXLEN], wnome[MAXLEN], wnome2[MAXLEN]; + char arqou[MAXLEN], arqin[MAXLEN], wnome[MAXLEN]; char field1[10]="2,2"; char field2[10]="1,1"; char field3[10]="3,3"; @@ -42,29 +44,40 @@ void tmpsort() if(indexonly) return; if(strstr(ReportType,"users_sites") == 0) return; - wnome[0]='\0'; - wnome2[0]='\0'; + strup(UserSortField); + if(strcmp(UserSortField,"CONNECT") == 0) { + strcpy(field1,"1,1"); + strcpy(field2,"2,2"); + strcpy(field3,"3,3"); + } else if(strcmp(UserSortField,"SITE") == 0) { + strcpy(field1,"3,3"); + strcpy(field2,"2,2"); + strcpy(field3,"1,1"); + } else if(strcmp(UserSortField,"TIME") == 0) { + strcpy(field1,"5,5"); + strcpy(field2,"2,2"); + strcpy(field3,"1,1"); + } + + strlow(UserSortOrder); + if(strcmp(UserSortOrder,"normal") == 0) + order[0]='\0'; dirp = opendir(tmp); while ((direntp = readdir( dirp )) != NULL ){ - if(strstr(direntp->d_name,".utmp") == 0) + dlen=strlen(direntp->d_name)-(sizeof(tmpext)-1); + if (dlen<0) continue; + if(strcmp(direntp->d_name+dlen,tmpext) != 0) continue; - strcpy(wentp,direntp->d_name); - - wnome[0]='\0'; - striptmp: - if (getword(wnome2,sizeof(wnome2),wentp,'.')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",tmp); - exit(1); - } - strcat(wnome,wnome2); - - if(strcmp(wentp,"utmp") !=0) { - strcat(wnome,"."); - goto striptmp; + if (dlen>0) { + if (dlen>=sizeof(wnome)) continue; + strncpy(wnome,direntp->d_name,dlen); + wnome[dlen]=0; + } else { + wnome[0]='\0'; } - + strcpy(arqou,tmp); strcat(arqou,"/"); strcpy(arqin,arqou); @@ -76,30 +89,6 @@ void tmpsort() debuga(msg); } - strup(UserSortField); - strlow(UserSortOrder); - - if(strcmp(UserSortField,"CONNECT") == 0) { - strcpy(field1,"1,1"); - strcpy(field2,"2,2"); - strcpy(field3,"3,3"); - } - - if(strcmp(UserSortField,"SITE") == 0) { - strcpy(field1,"3,3"); - strcpy(field2,"2,2"); - strcpy(field3,"1,1"); - } - - if(strcmp(UserSortField,"TIME") == 0) { - strcpy(field1,"5,5"); - strcpy(field2,"2,2"); - strcpy(field3,"1,1"); - } - - if(strcmp(UserSortOrder,"normal") == 0) - order[0]='\0'; - strcat(arqou,".txt"); sprintf(csort,"sort -n -T %s %s -k %s -k %s -k %s -o '%s' '%s'",TempDir,order,field1,field2,field3,arqou,arqin); cstatus=system(csort); @@ -112,21 +101,21 @@ void tmpsort() } - (void)rewinddir( dirp ); (void)closedir( dirp ); return; } -void sort_users_log(char *tmp, int debug) +void sort_users_log(const char *tmp, int debug) { - DIR *dirp; struct dirent *direntp; char csort[MAXLEN]; char wtmp[MAXLEN]; - char wname2[MAXLEN]; + char user[MAXLEN]; char wdname[MAXLEN]; int cstatus; + const char unsortext[]=".unsort"; + int dlen; if(debug) { sprintf(msg,"%s",text[138]); @@ -137,24 +126,19 @@ void sort_users_log(char *tmp, int debug) dirp = opendir(wtmp); while ( (direntp = readdir( dirp )) != NULL ){ - if(strstr(direntp->d_name,".unsort") == 0) + dlen=strlen(direntp->d_name)-(sizeof(unsortext)-1); + if (dlen<0) continue; + if(strcmp(direntp->d_name+dlen,unsortext) != 0) continue; - if(strcmp(direntp->d_name,"denied.log") == 0 || strcmp(direntp->d_name,"authfail.log.unsort") == 0) + if(strcmp(direntp->d_name,"authfail.log.unsort") == 0) continue; - strcpy(wdname,direntp->d_name); - - bzero(user, MAXLEN); - strip_unsort: - if (getword(wname2,sizeof(wname2),wdname,'.')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",wtmp); - exit(1); - } - strcat(user,wname2); - - if(strcmp(wdname,"unsort") !=0) { - strcat(user,"."); - goto strip_unsort; + if (dlen>0) { + if (dlen>=sizeof(user)) continue; + strncpy(user,direntp->d_name,dlen); + user[dlen]=0; + } else { + bzero(user, MAXLEN); } if(strcmp(direntp->d_name,"download.unsort") == 0) @@ -169,12 +153,14 @@ void sort_users_log(char *tmp, int debug) fprintf(stderr, "SARG: sort command: %s\n",csort); exit(1); } - sprintf(wdname,"%s/%s.unsort",wtmp,user); + if (snprintf(wdname,sizeof(wdname),"%s/%s.unsort",wtmp,user)>=sizeof(wdname)) { + fprintf(stderr, "SARG: user name too long for: %s/%s.unsort\n",wtmp,user); + exit(1); + } unlink(wdname); bzero(user, MAXLEN); } - (void)rewinddir( dirp ); (void)closedir( dirp ); return; diff --git a/splitlog.c b/splitlog.c index a8d0e74..aa535b7 100644 --- a/splitlog.c +++ b/splitlog.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void splitlog(char *arq, char *df, int dfrom, int duntil, char *convert) +void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert) { FILE *fp_in; @@ -39,10 +39,10 @@ void splitlog(char *arq, char *df, int dfrom, int duntil, char *convert) struct tm *t; if(arq[0] == '\0') - strcpy(arq,"/usr/local/squid/logs/access.log"); + arq="/usr/local/squid/logs/access.log"; #if defined(HAVE_FOPEN64) - if((fp_in=(long)fopen64(arq,"r"))==NULL) { + if((fp_in=fopen64(arq,"r"))==NULL) { #else if((fp_in=fopen(arq,"r"))==NULL) { #endif diff --git a/squidguard_log.c b/squidguard_log.c index e1276e4..bdbd9e3 100644 --- a/squidguard_log.c +++ b/squidguard_log.c @@ -161,16 +161,14 @@ void read_log(char *wentp, FILE *fp_ou) } -int squidguard_log() +void squidguard_log(void) { - FILE *fp_ou = NULL, *fp_guard = NULL; char guard_in[MAXLEN]; char guard_ou[MAXLEN]; char logdir[MAXLEN]; char year[10], day[10], mon[10]; char user[MAXLEN]; - char ip[30]; int x, y; int cstatus; diff --git a/squidguard_report.c b/squidguard_report.c index ada1d45..f383f38 100644 --- a/squidguard_report.c +++ b/squidguard_report.c @@ -25,16 +25,14 @@ #include "include/conf.h" -void squidguard_report() +void squidguard_report(void) { FILE *fp_in = NULL, *fp_ou = NULL; char url[MAXLEN]; - char html[MAXLEN]; char html2[MAXLEN]; char squidguard_in[MAXLEN]; - char squidguard_ou[MAXLEN]; char per[MAXLEN]; char report[MAXLEN]; char period[100]; @@ -46,7 +44,6 @@ void squidguard_report() char data[15]; char data2[15]; char hora[15]; - char ftime[128]; char *str; int z=0; int count=0; diff --git a/topsites.c b/topsites.c index cf79585..3f1b26b 100644 --- a/topsites.c +++ b/topsites.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void topsites() +void topsites(void) { FILE *fp_in, *fp_ou; @@ -265,7 +265,7 @@ void topsites() sprintf(wwork1,"%s",fixnum(twork1,1)); sprintf(wwork2,"%s",fixnum(twork2,1)); - sprintf(wwork3,"%s",fixtime(twork3,1)); + sprintf(wwork3,"%s",fixtime(twork3)); if(strlen(BlockIt) > 0) sprintf(BlockImage," ",wwwDocumentRoot,BlockIt,url); diff --git a/topuser.c b/topuser.c index d172ef9..006bae4 100644 --- a/topuser.c +++ b/topuser.c @@ -25,7 +25,7 @@ #include "include/conf.h" -int topuser() +void topuser(void) { FILE *fp_in = NULL, *fp_ou = NULL, *fp_top1 = NULL, *fp_top2 = NULL, *fp_top3 = NULL; @@ -416,15 +416,13 @@ int topuser() if(strstr(ReportType,"date_time") != 0) { sprintf(ltext110,"%s",text[110]); - if(ltext110){ - for(s=ltext110; *s; ++s) - *s=tolower(*s); - } + for(s=ltext110; *s; ++s) + *s=tolower(*s); } else { bzero(href2, MAXLEN); bzero(ltext110, 50); sprintf(val1,"%s/d%s.html",dirname,user); - unlink(val1); + unlink(val1); } // if(UserTabFile[0] != '\0' && strstr(user2,".") != 0) { diff --git a/totday.c b/totday.c index fb1b079..efd08c7 100644 --- a/totday.c +++ b/totday.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void day_totalize(const char *tmp, char *user, int indexonly) +void day_totalize(const char *tmp, const char *user, int indexonly) { FILE *fp_in, *fp_ou; diff --git a/totger.c b/totger.c index e6543ef..01d7bfd 100644 --- a/totger.c +++ b/totger.c @@ -26,10 +26,7 @@ #include "include/conf.h" int totalger(const char *dirname, int debug, const char *outdir) - { - - FILE *fp_in, *fp_ou; long long int tnacc=0; long long int tnbytes=0; diff --git a/usage.c b/usage.c index 3a7620d..4ccc40d 100644 --- a/usage.c +++ b/usage.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void usage(char *prog) +void usage(const char *prog) { fprintf(stderr, "%s: %s [%s...]\n", prog,text[39],text[40]); fprintf(stderr, "%5s-a %s\n"," ",text[23]); diff --git a/useragent.c b/useragent.c index 15ed405..b467df4 100644 --- a/useragent.c +++ b/useragent.c @@ -25,7 +25,7 @@ #include "include/conf.h" -void useragent() +void useragent(void) { FILE *fp_in = NULL, *fp_ou = NULL, *fp_ht = NULL; diff --git a/util.c b/util.c index bd5200c..56c9feb 100644 --- a/util.c +++ b/util.c @@ -197,7 +197,7 @@ long long int my_atoll (const char *nptr) long long int my_atoll (const char *nptr) { long long int returnval=0; - char * t = nptr ; + const char * t = nptr ; int max_digits = MAXLLL ; // Soak up all the white space @@ -221,7 +221,7 @@ long long int my_atoll (const char *nptr) #endif -void my_mkdir(char *name) +void my_mkdir(const char *name) { char w0[255]; char w1[255]; @@ -297,7 +297,7 @@ void my_lltoa(unsigned long long int n, char s[], int len) } -void builddia(char *dia, char *mes, char *ano, char *df, char *wdata) +void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata) { char ndia[11]; char nmes[3]; @@ -328,7 +328,7 @@ void builddia(char *dia, char *mes, char *ano, char *df, char *wdata) } -void buildymd(char *dia, char *mes, char *ano, char *wdata) +void buildymd(const char *dia, const char *mes, const char *ano, char *wdata) { char nmes[3]; int x; @@ -388,7 +388,7 @@ void name_month(char *month,int month_len) } -void fixper(char *tbuf, char *period, char *duntil) +void fixper(char *tbuf, char *period, const char *duntil) { char warea[50]; @@ -405,8 +405,10 @@ void fixper(char *tbuf, char *period, char *duntil) ano[4]='\0'; for(x=0; x<12; x++) { - if(strcmp(mtab2[x],mes) == 0) + if(strcmp(mtab2[x],mes) == 0) { strcpy(mes,mtab1[x]); + break; + } } if(strcmp(df,"e") == 0) @@ -418,14 +420,14 @@ void fixper(char *tbuf, char *period, char *duntil) } -void debuga(char *msg) +void debuga(const char *msg) { fprintf(stderr, "SARG: %s\n",msg); } -void debugaz(char *head, char *msg) +void debugaz(const char *head, const char *msg) { fprintf(stderr, "SARG: (util) %s=%s\n",head, msg); @@ -464,12 +466,12 @@ void fixip(char *ip) char *fixnum(long long int value, int n) -#define MAXLEN 1024 { - char num[MAXLEN]; - char buf[MAXLEN * 2]; +#define MAXLEN_FIXNUM 1024 + char num[MAXLEN_FIXNUM]; + char buf[MAXLEN_FIXNUM * 2]; char *pbuf; - static char ret[MAXLEN * 2]; + static char ret[MAXLEN_FIXNUM * 2]; char *pret; register int i, j, k; static char abbrev[30]; @@ -525,7 +527,7 @@ char *fixnum(long long int value, int n) return(abbrev); } - bzero(buf, MAXLEN*2); + bzero(buf, MAXLEN_FIXNUM*2); pbuf = buf; pret = ret; @@ -557,18 +559,17 @@ char *fixnum(long long int value, int n) char *fixnum2(long long int value, int n) -#define MAXLEN 1024 { - char num[MAXLEN]; - char buf[MAXLEN * 2]; +#define MAXLEN_FIXNUM2 1024 + char num[MAXLEN_FIXNUM2]; + char buf[MAXLEN_FIXNUM2 * 2]; char *pbuf; - static char ret[MAXLEN * 2]; + static char ret[MAXLEN_FIXNUM2 * 2]; char *pret; register int i, j, k; - static char abbrev[30]; my_lltoa(value, num, 0); - bzero(buf, MAXLEN*2); + bzero(buf, MAXLEN_FIXNUM2*2); pbuf = buf; pret = ret; @@ -593,9 +594,9 @@ char *fixnum2(long long int value, int n) for ( i = strlen(pbuf) - 1, j = 0 ; i > -1; i--, j++) pret[j] = pbuf[i]; - pret[j] = '\0'; + pret[j] = '\0'; - return pret; + return pret; } @@ -643,7 +644,7 @@ char *buildtime(long long int elap) } -void obtdate(char *dirname, char *name, char *data) +void obtdate(const char *dirname, const char *name, char *data) { FILE *fp_in; @@ -667,7 +668,7 @@ void obtdate(char *dirname, char *name, char *data) } -void obtuser(char *dirname, char *name, char *tuser) +void obtuser(const char *dirname, const char *name, char *tuser) { FILE *fp_in; @@ -691,7 +692,7 @@ void obtuser(char *dirname, char *name, char *tuser) } -void obttotal(char *dirname, char *name, char *tbytes, char *tuser, char *media) +void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media) { FILE *fp_in; @@ -744,7 +745,7 @@ void obttotal(char *dirname, char *name, char *tbytes, char *tuser, char *media) //void gperiod(char *dirname, const char *period) -void gperiod() +void gperiod(void) { FILE *fp_ou; @@ -770,7 +771,7 @@ void gperiod() } -void vrfydir(char *dir, char *per1, char *addr, char *site, char *us, char *form) +void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form) { FILE *img_in, *img_ou; int num=1, count=0; @@ -782,6 +783,9 @@ void vrfydir(char *dir, char *per1, char *addr, char *site, char *us, char *form DIR *dirp; struct dirent *direntp; int cstatus; + char y1[5], y2[5]; + char d1[3], d2[3]; + char m1[4], m2[4]; if(strcmp(IndexTree,"date") == 0) { bzero(y1,5); @@ -832,7 +836,7 @@ void vrfydir(char *dir, char *per1, char *addr, char *site, char *us, char *form strncat(wdir,d2,strlen(d2)); } } else - sprintf(wdir,"%s",dir); + strcpy(wdir,dir); if(strlen(us) > 0) { strcat(wdir,"-"); @@ -979,7 +983,7 @@ void strip_latin(char *line) } -void zdate(char *ftime, char *DateFormat) +void zdate(char *ftime, const char *DateFormat) { time_t t; @@ -1066,15 +1070,15 @@ void date_from(char *date, char *dfrom, char *duntil) char *strlow(char *string) { - char *s; + char *s; - if (string) - { - for (s = string; *s; ++s) - *s = tolower(*s); - } + if (string) + { + for (s = string; *s; ++s) + *s = tolower(*s); + } - return string; + return string; } @@ -1082,15 +1086,15 @@ char *strlow(char *string) char *strup(char *string) { - char *s; + char *s; - if (string) - { - for (s = string; *s; ++s) - *s = toupper(*s); - } + if (string) + { + for (s = string; *s; ++s) + *s = toupper(*s); + } - return string; + return string; } @@ -1123,43 +1127,45 @@ char *subs(char *str, char *from, char *to) } -void removetmp(char *outdir) +void removetmp(const char *outdir) { FILE *fp_in; char warea[256]; - if(strcmp(RemoveTempFiles,"yes") != 0) { + if(strcmp(RemoveTempFiles,"yes") != 0) return; - } else { - if(debug) { - sprintf(msg,"%s: sarg-general, sarg-period",text[82]); - debuga(msg); - } - sprintf(warea,"%s/sarg-general",outdir); - if((fp_in=fopen(warea,"r"))==NULL){ - fprintf(stderr, "===SARG: (removetmp) %s: %s\n",text[45],warea); - exit(1); - } - while(fgets(buf,sizeof(buf),fp_in)!=NULL) { - if(strncmp(buf,"TOTAL",5) == 0) - break; - } - fclose(fp_in); - if((fp_in=fopen(warea,"w"))==NULL){ - fprintf(stderr, "SARG: (removetmp) %s: %s\n",text[45],warea); - exit(1); - } - fputs(buf,fp_in); - fclose(fp_in); - sprintf(warea,"%s/sarg-period",outdir); - unlink(warea); + + if(debug) { + sprintf(msg,"%s: sarg-general, sarg-period",text[82]); + debuga(msg); + } + sprintf(warea,"%s/sarg-general",outdir); + if((fp_in=fopen(warea,"r"))==NULL){ + fprintf(stderr, "===SARG: (removetmp) %s: %s\n",text[45],warea); + exit(1); + } + while(fgets(buf,sizeof(buf),fp_in)!=NULL) { + if(strncmp(buf,"TOTAL",5) == 0) + break; + } + fclose(fp_in); + if((fp_in=fopen(warea,"w"))==NULL){ + fprintf(stderr, "SARG: (removetmp) %s: %s\n",text[45],warea); + exit(1); } + fputs(buf,fp_in); + fclose(fp_in); + if (snprintf(warea,sizeof(warea),"%s/sarg-period",outdir)>=sizeof(warea)) { + fprintf(stderr, "SARG: (removetmp) directory too long to remove: %s/sarg-period\n",outdir); + exit(1); + } + unlink(warea); return; } -void load_excludecodes() +void load_excludecodes(void) { FILE *fp_in; @@ -1170,7 +1176,7 @@ void load_excludecodes() exit(1); } - while(fgets(data,80,fp_in)!=NULL) { + while(fgets(data,sizeof(data),fp_in)!=NULL) { data[strlen(data)-1]='\0'; strcat(excludecode,data); strcat(excludecode,";"); @@ -1182,7 +1188,7 @@ void load_excludecodes() } -int vercode(char *code) +int vercode(const char *code) { char warea[1024]; char cod[80]; @@ -1202,8 +1208,10 @@ int vercode(char *code) void fixnone(char *str) { - if(strstr(str,"\n") != 0) - str[strlen(str)-1]='\0'; + char *eol; + + eol=strchr(str,'\n'); + if (eol) *eol=0; if(strcmp(str,"none") == 0) str[0]='\0'; @@ -1211,7 +1219,7 @@ void fixnone(char *str) } #ifdef LEGACY_TESTVALIDUSERCHAR -int testvaliduserchar(char *user) +int testvaliduserchar(const char *user) { int x=0; @@ -1226,11 +1234,11 @@ int testvaliduserchar(char *user) return 0; } #else -int testvaliduserchar(char *user) +int testvaliduserchar(const char *user) { char * p_UserInvalidChar = UserInvalidChar ; - char * p_user ; + const char * p_user ; while( *p_UserInvalidChar ) { p_user = user ; @@ -1307,21 +1315,25 @@ void show_info(FILE *fp_ou) fprintf(fp_ou,"


%s %s-%s %s %s
\n",text[108],URL,PGM,VERSION,text[109],ftime); } -void show_sarg(FILE *fp_ou, char *ind) +void show_sarg(FILE *fp_ou, const char *ind) { if(strcmp(ShowSargLogo,"yes") == 0) fprintf(fp_ou,"
\n\n\n
 Squid Analysis Report Generator
 
\n",ind); } -int get_size(char *path, char *file) +char *get_size(const char *path, const char *file) { FILE *fp; char response[255]; + char cmd[255]; - sprintf(cmd,"du -skh %s%s",path,file); + if (snprintf(cmd,sizeof(cmd),"du -skh %s%s",path,file)>=sizeof(cmd)) { + printf("SARG: Cannot get disk space because the path %s%s is too long.\n",path,file); + exit(1); + } fp = popen(cmd, "r"); - fgets(response, 255, fp); + fgets(response, sizeof(response), fp); if (getword_multisep(val5,sizeof(val5),response,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s command.\n",cmd); + printf("SARG: Maybe the command %s failed.\n",cmd); exit(1); } pclose(fp); @@ -1330,7 +1342,7 @@ int get_size(char *path, char *file) } -void write_html_header(FILE *fp_ou, char * ind) +void write_html_header(FILE *fp_ou, const char * ind) { fprintf(fp_ou, "\n\n\n \n\n",CharSet); css(fp_ou); @@ -1340,7 +1352,7 @@ void write_html_header(FILE *fp_ou, char * ind) fprintf(fp_ou,"
\n\n
%s
\n
\n\n",Title); } -void baddata() +void baddata(void) { printf("SARG: ------------------------------------------------------------------------------\n"); printf("SARG: MALICIUS CODE DETECTED.\n"); @@ -1358,7 +1370,7 @@ void baddata() } -char url_module(char *url, char *w2) +void url_module(char *url, char *w2) { int x, y; char w[255]; @@ -1377,8 +1389,6 @@ char url_module(char *url, char *w2) w2[y]=w[x]; y++; } - - return; } @@ -1390,7 +1400,7 @@ void write_html_trailer(FILE *fp_ou) fputs("\n\n",fp_ou); } -void version() +void version(void) { printf("SARG Version: %s\n",VERSION); exit(0); -- 2.39.2