Add cmake configuration files.
--- /dev/null
+CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
+PROJECT(sarg C)
+SET(sarg_VERSION 2)
+SET(sarg_REVISION 2)
+SET(sarg_BUILD 5)
+SET(sarg_BUILDDATE "Sep-12-2009")
+
+INCLUDE(AddFileDependencies)
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckTypeSize)
+INCLUDE(CheckSymbolExists)
+
+DEFINE_PROPERTY(GLOBAL PROPERTY enable-htmldir BRIEF_DOCS "--enable-htmldir=htmldir"
+ FULL_DOCS "Select htmldir as the root of your WWW documents")
+
+SET(PACKAGE_NAME "sarg")
+SET(PACKAGE_VERSION "${sarg_VERSION}.${sarg_REVISION}.${sarg_BUILD} ${sarg_BUILDDATE}")
+
+MACRO(SET_ABS_SOURCE VAR DOC)
+ IF(${VAR} AND NOT ${VAR}_SOURCE)
+ SET(PATH "${${VAR}}")
+ IF(NOT IS_ABSOLUTE ${PATH})
+ SET(SOURCE_PATH "${CMAKE_INSTALL_PREFIX}/${PATH}")
+ ENDIF(NOT IS_ABSOLUTE ${PATH})
+ GET_FILENAME_COMPONENT(SOURCE_PATH "${SOURCE_PATH}" ABSOLUTE)
+ SET(${VAR}_SOURCE "${SOURCE_PATH}" CACHE PATH "${DOC}")
+ ENDIF(${VAR} AND NOT ${VAR}_SOURCE)
+ENDMACRO(SET_ABS_SOURCE VAR DOC)
+
+SET_ABS_SOURCE(SYSCONFDIR "The full path of the configuration directory to be compiled in the program")
+SET_ABS_SOURCE(LANGDIR "The full path of the language directory to be compiled in the program")
+SET_ABS_SOURCE(FONTDIR "The full path of the fonts directory to be compiled in the program")
+SET_ABS_SOURCE(IMAGEDIR "The full path of the images directory to be compiled in the program")
+
+SET(SYSCONFDIR "etc/sarg" CACHE PATH "The configuration directory relative to the install directory")
+SET(BINDIR "bin" CACHE PATH "The directory to install the exec relative to the install directory")
+SET(MANDIR "share/man" CACHE PATH "The directory to copy the man page relative to the install directory")
+SET(LANGDIR "share/sarg/languages" CACHE PATH "The directory to copy the languages files relative to the install directory")
+SET(FONTDIR "share/sarg/fonts" CACHE PATH "The directory to copy the fonts relative to the install directory")
+SET(IMAGEDIR "share/sarg/images" CACHE PATH "The directory to copy the images files relative to the install directory")
+
+# Sources to compile
+INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}") #Make it find this config.h before the one in src/include
+INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
+SET(SRC util.c log.c report.c topuser.c email.c sort.c html.c
+ totger.c index.c getconf.c usage.c decomp.c ip2name.c
+ useragent.c exclude.c convlog.c totday.c repday.c datafile.c
+ indexonly.c splitlog.c lastlog.c topsites.c siteuser.c css.c
+ smartfilter.c denied.c authfail.c language.c charset.c
+ squidguard_log.c squidguard_report.c auth.c download.c grepday.c
+ dansguardian_log.c dansguardian_report.c realtime.c)
+
+FOREACH(f ${SRC})
+ ADD_FILE_DEPENDENCIES(${f} ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/include/conf.h ${CMAKE_SOURCE_DIR}/include/info.h ${CMAKE_SOURCE_DIR}/include/defs.h)
+ENDFOREACH(f)
+
+ADD_EXECUTABLE(sarg ${SRC})
+
+SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAG "${CFLAGS} -Wall -Werror=implicit-function-declaration")
+SET_TARGET_PROPERTIES(sarg PROPERTIES VERSION "${sarg_VERSION}.${sarg_REVISION}.${sarg_BUILD}")
+
+# Required header files
+CHECK_INCLUDE_FILE(stdio.h HAVE_STDIO_H)
+CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
+CHECK_INCLUDE_FILE(string.h HAVE_STRING_H)
+CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
+CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILE(time.h HAVE_TIME_H)
+CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILE(sys/dirent.h HAVE_SYS_DIRENT_H)
+CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
+CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
+CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H)
+CHECK_INCLUDE_FILE(arpa/inet.h HAVE_ARPA_INET_H)
+CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_H)
+CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE(ctype.h HAVE_CTYPE_H)
+CHECK_INCLUDE_FILE(errno.h HAVE_ERRNO_H)
+CHECK_INCLUDE_FILE(sys/resource.h HAVE_SYS_RESOURCE_H)
+CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
+CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H)
+CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
+CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H)
+
+CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
+
+# Find gd
+CHECK_INCLUDE_FILE(gd.h HAVE_GD_H)
+IF(HAVE_GD_H)
+ CHECK_INCLUDE_FILE(gdfontl.h HAVE_GDFONTL_H)
+ CHECK_INCLUDE_FILE(gdfontt.h HAVE_GDFONTT_H)
+ CHECK_INCLUDE_FILE(gdfonts.h HAVE_GDFONTS_H)
+ CHECK_INCLUDE_FILE(gdfontmb.h HAVE_GDFONTMB_H)
+ CHECK_INCLUDE_FILE(gdfontg.h HAVE_GDFONTG_H)
+ FIND_LIBRARY(GD_LIBRARY NAMES gd PATHS /usr/lib /usr/local/lib DOC "The GD library")
+ IF(GD_LIBRARY)
+ #CHECK_LIBRARY_EXISTS(gd gdImagePng "." HAVE_GD)
+ TARGET_LINK_LIBRARIES(sarg gd)
+ SET(HAVE_GD GD_LIBRARY CACHE PATH DOC "True IF GD was found")
+ SET(HAVE_GD CACHE BOOL DOC "True IF must use GD")
+ ENDIF(GD_LIBRARY)
+ENDIF(HAVE_GD_H)
+
+# Find iconv
+OPTION(ENABLE_ICONV "Enable the usage of iconv" ON)
+IF(ENABLE_ICONV)
+ CHECK_INCLUDE_FILE(iconv.h HAVE_ICONV_H)
+ IF(HAVE_ICONV_H)
+ CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV)
+ IF(!HAVE_ICONV)
+ FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h PATHS /usr/include /usr/local/include)
+ FIND_LIBRARY(ICONV_LIBRARY NAMES iconv PATHS /lib /usr/lib /usr/local/lib DOC "The ICONV library")
+ ENDIF(!HAVE_ICONV)
+
+ SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
+ FILE(WRITE ${ICONV_CONST_FILE} "
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+")
+ TRY_COMPILE(USE_CONST_ICONV ${CMAKE_BINARY_DIR} ${ICONV_CONST_FILE})
+ FILE(REMOVE ${ICONV_CONST_FILE})
+ IF(USE_CONST_ICONV)
+ SET(ICONV_CONST "\"const\"")
+ ENDIF(USE_CONST_ICONV)
+ ENDIF(HAVE_ICONV_H)
+ENDIF(ENABLE_ICONV)
+
+# Support for large files
+OPTION(ENABLE_LARGEFILE "Enable the usage of large files" ON)
+IF(ENABLE_LARGEFILE)
+ IF(LFS_SEARCHED MATCHES "^LFS_SEARCHED$")
+ SET(SEARCH_LARGEFILE TRUE)
+ ENDIF(LFS_SEARCHED MATCHES "^LFS_SEARCHED$")
+ENDIF(ENABLE_LARGEFILE)
+
+IF(SEARCH_LARGEFILE)
+ SET(LFS_SEARCHED TRUE CACHE INTERNAL "LFS has been searched")
+ MESSAGE(STATUS "Looking for large file support")
+ SET(LFS_FILE "${CMAKE_BINARY_DIR}/lfsfopen64.c")
+ FILE(WRITE ${LFS_FILE} "
+#include <stdio.h>
+int main(void)
+{
+FILE *f = fopen64 (\"/tmp/foo\",\"r\");
+return(0);
+}
+")
+ TRY_COMPILE(HAVE_FOPEN64 ${CMAKE_BINARY_DIR} ${LFS_FILE} COMPILE_DEFINITIONS "-Wall -Werror")
+ IF(HAVE_FOPEN64)
+ MESSAGE(STATUS "Looking for large file support - found")
+ ELSE(HAVE_FOPEN64)
+ SET(LFS_NEED_DEFINE FALSE CACHE BOOL "Does LFS require _LARGEFILE64_SOURCE ?")
+ MESSAGE(STATUS "Looking for large file support with _LARGEFILE64_SOURCE")
+ FILE(WRITE ${LFS_FILE} "
+#define _LARGEFILE64_SOURCE
+#include <stdio.h>
+int main(void)
+{
+FILE *f = fopen64 (\"/tmp/foo\",\"r\");
+return(0);
+}
+")
+ TRY_COMPILE(HAVE_FOPEN64 ${CMAKE_BINARY_DIR} ${LFS_FILE} OUTPUT_VARIABLE LFS_OUTPUT)
+ IF(HAVE_FOPEN64)
+ MESSAGE(STATUS "Looking for large file support with _LARGEFILE64_SOURCE - found")
+ SET(LFS_NEED_DEFINE TRUE CACHE BOOL "Does LFS require _LARGEFILE64_SOURCE ?" FORCE)
+ ELSE(HAVE_FOPEN64)
+ MESSAGE("Failed with output ${LFS_OUTPUT}")
+ ENDIF(HAVE_FOPEN64)
+ ENDIF(HAVE_FOPEN64)
+ FILE(REMOVE ${LFS_FILE})
+ENDIF(SEARCH_LARGEFILE)
+
+IF(LFS_NEED_DEFINE)
+ ADD_DEFINITIONS(-D_LARGEFILE64_SOURCE)
+ENDIF(LFS_NEED_DEFINE)
+
+# Find off_t size
+check_type_size(off_t OFF_T)
+IF(HAVE_OFF_T)
+ IF(OFF_T STREQUAL 4)
+ SET(OFFSET_STRING "\"%d\"")
+ elseif(OFF_T STREQUAL 8)
+ SET(OFFSET_STRING "\"%\"PRId64")
+ ENDIF(OFF_T STREQUAL 4)
+ELSE(HAVE_OFF_T)
+ MESSAGE(FATAL_ERROR Need off_t to compile the program)
+ENDIF(HAVE_OFF_T)
+
+# Find rlim_t
+IF(HAVE_SYS_RESOURCE_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES "sys/resource.h")
+ENDIF(HAVE_SYS_RESOURCE_H)
+CHECK_TYPE_SIZE(rlim_t RLIM_T)
+IF(HAVE_RLIM_T)
+ IF(RLIM_T STREQUAL 4)
+ SET(RLIM_STRING "%d")
+ ELSEIF(RLIM_T STREQUAL 8)
+ SET(RLIM_STRING "%lli")
+ ELSE(RLIM_T STREQUAL 4)
+ MESSAGE("Unknown rlim_t size")
+ ENDIF(RLIM_T STREQUAL 4)
+ELSE(HAVE_RLIM_T)
+ MESSAGE("Cannot detect the size of your system's rlim_t type")
+ENDIF(HAVE_RLIM_T)
+
+# Windows need lib wsock32
+IF(CMAKE_SYSTEM_NAME EQUAL "Windows")
+ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
+ CHECK_INCLUDE_FILE(winsock.h HAVE_WINSOCK_H)
+ FIND_LIBRARY(WSOCK_LIB NAMES wsock32 PATHS /usr/lib /usr/local/lib DOC "The winsock library")
+ #check_library_exists(wsock32 "." HAVE_WSOCK)
+ IF(WSOCK_LIB)
+ #set_target_properties(sarg PROPERTIES LINK_FLAGS "${LINK_FLAGS} -lwsock32")
+ TARGET_LINK_LIBRARIES(sarg wsock32)
+ ENDIF(WSOCK_LIB)
+ENDIF(CMAKE_SYSTEM_NAME EQUAL "Windows")
+
+CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
+IF(!HAVE_MKSTEMP)
+ # MingW provide mkstemps in libiberty but doesn't declare it in any header file
+ FIND_LIBRARY(IBERTY_LIB NAMES iberty PATHS /mingw/lib DOC "The library of mingw containing mkstemps")
+ IF(IBERTY_LIB)
+ TARGET_LINK_LIBRARIES(sarg iberty)
+ ENDIF(IBERTY_LIB)
+ENDIF(!HAVE_MKSTEMP)
+
+# System particularities
+IF(CMAKE_SYSTEM_NAME EQUAL "solaris")
+ TARGET_LINK_LIBRARIES(sarg socket nsl)
+ #SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_DEFINITIONS="-DSOLARIS ${COMPILE_DEFINITIONS}")
+ ADD_DEFINITIONS(-DSOLARIS)
+ENDIF(CMAKE_SYSTEM_NAME EQUAL "solaris")
+
+# Save the configuration for the project
+CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/include/config.h.in" "${CMAKE_BINARY_DIR}/config.h" @ONLY)
+
+# Installation of the project
+INSTALL(TARGETS sarg DESTINATION "${BINDIR}")
+INSTALL(FILES sarg.conf exclude_codes user_limit_block css.tpl DESTINATION "${SYSCONFDIR}")
+INSTALL(FILES sarg.1 DESTINATION "${MANDIR}")
+INSTALL(DIRECTORY languages/ DESTINATION "${LANGDIR}" PATTERN "CVS" EXCLUDE)
+INSTALL(DIRECTORY images/ DESTINATION "${IMAGEDIR}" PATTERN "CVS" EXCLUDE)
+INSTALL(DIRECTORY fonts/ DESTINATION "${FONTDIR}" FILES_MATCHING PATTERN "*.ttf" PATTERN "CVS" EXCLUDE)
+
+# Package creation
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Squid Analysis Report Generator")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${sarg_VERSION}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${sarg_REVISION}")
+SET(CPACK_PACKAGE_VERSION_PATCH "${sarg_BUILD}")
+SET(CPACK_GENERATOR TGZ)
+SET(CPACK_SOURCE_GENERATOR TGZ)
+SET(CPACK_SOURCE_IGNORE_FILES "/CVS/" "/debian/" "/html/" "Makefile$" "config\\\\.log$" "config\\\\.status$" ".*~$" "\\\\.o$")
+INCLUDE(CPack)
SARG ChangeLog
+Sep-12-2009 Version 2.2.6rc
+ - Protection against buffer overflows in getword and friends and report the origin of the error instead of always blaming access.log.
+ - Patch #2224623 applied.
+ - Updated to autoconf 2.61.
+ - Detect external commands failures and print the exact command that produced the error. The offending file is kept for debugging if possible.
+ - The format of the date written in sarg-date is forced to prevent a failure if the locale is not en_US.
+ - Removed the duplicate file opening that resulted in a resource leak.
+ - Patch #1945235 applied.
+ - Patch #1918397 applied.
+ - Limit the content of the squidguard log file to the date of the day being processed.
+ - Removed fscanf that is prone to buffer overflows.
+ - Size of buffers increased.
+ - Protect ip2name against buffer overflows.
+ - Replace characters that are valid in URL but not in file names when building a file name from a URL.
+ - Patch #2657320 applied.
+ - Fix #else #if into #elif.
+ - Remove all the compilation warnings (inspired from patch #1771501).
+ - Fixed the real time report.
+ - Fixed the same bug as patch #1733337 but in a cleaner way.
+ - All the sprintf/fputs have been replaced by fprintf to avoid an intermediary buffer and possible buffer overflow.
+ - Moved all the functions declarations from conf.h to defs.h for consistency.
+ - Fixed bug #2089451.
+ - Fixed Debian bug #444845.
+ - Replaced the ifdef FOPEN64 by a single call to MY_FOPEN for code clarity.
+ - User IP/ID is searched only in the first column of the usertab file.
+ - Some of indentation fixes.
+ - Speed up by removing two uncessary ip resolutions.
+ - Applied debian patches: sarg-polish.patch, sarg-turkish.patch
+ - Applied debian patch: opensuse_2_enlarge_report_buffers.patch
+ - Applied debian patch: opensuse_3_too_small_font_buffer.patch
+ - Applied debian patch: opensuse_4_enlarge_log_buffer.patch
+ - Applied and extended debian patch: opensuse_5_limit_sprintf.patch
+ - Function debuga format the output string itself, so there is no need to use sprintf.
+ - Applied debian patch: opensuse_7_year_assertion.patch
+ - Removed a few unecessary strings copy.
+ - Embryo of documentation for the code with doxygen.
+ - Changed subs to replace the string in place and avoid allocating a memory that was freed on only one occasion.
+ - A few improvements on strings manipulations.
+ - Fixed debian bug #504749.
+ - Detect downloaded suffix bigger than 3 characters, don't match the cases and don't stop on a partial match.
+ - Fixed bug #2716729.
+ - Sanitized a little bit the generated HTML.
+ - Don't reject URL without directories.
+ - Use the correct format for off_t on amd64.
+ - Use the mechanism provided by configure to set the directories of the application instead of the custom variables.
+ - Fixed bug #1814212.
+ - Fixed bug #1847374.
+ - Partly applied advice of bug #1659784.
+ - Fixed bug #1740268.
+ - Applied suggestion of bug #2830643.
+ - Fixed bug #2216451.
+ - Fixed bug #2000178.
+ - Protect the reading of the configuration file against buffer overflows.
+ - Logo image height taken into account.
+ - Accept longer mail utility name.
+ - Fixed e-mail report (may also fix bug #2153024).
+ - Fixed total and percentages of topuser page.
+ - Applied Gentoo patch 10_all_sarg-2.2.5-enlarge-day-mon-buffers.patch.
+ - Applied Gentoo patch 12_all_sarg-2.2.5-enlarge-ntemp.patch.
+ - Open only once the denied.log and authfail.log when parsing more than one access.log.
+ - Use configurable paths for the files that used to reside in SYSCONFDIR.
+ - Add cmake configuration files.
+
Mar-03-2008 Version 2.2.5
- new fix to the script insertion vulnerability via user-agent
report. javascript can still be executed via e.g. the "<BODY onload=function();>" scheme
Thanks to Artem Korneev <akorneev@intelsysus.com>
- sort open failed causing an empty topuser report
- sarg losslessly size optimized images
- Thanks to Tonda Mí¿ek <tonda.misek@post.cz> and Luigi Gangitano.
+ Thanks to Tonda M��ek <tonda.misek@post.cz> and Luigi Gangitano.
- sarg calling sort without quoting filenames
Thanks to Luigi Gangitano.
- download_report_limit tag added.
an "emulate_httpd_log on" logfile and some performance improvements
added.
Thanks to Filippo Grassilli
- - Spanish language fixed by José Luis Hernández López. Thanks.
+ - Spanish language fixed by Jos� Luis Hern�ndez L�pez. Thanks.
- url variable size changed to acomodate big urls with coded symbols and some
minor changes in util.c file.
Thanks to Oleg <xsov@mail.ru>
- index_sort_order tag don't work correctly.
- too many open files fixed. Thanks to Francesco Perrillo <fperillo@totalfax.it>
- Ukrainian_windows1251 included in sarg.conf file
- - exclude_string don´t work correctly. Thanks to Modric Kristijan
+ - exclude_string don�t work correctly. Thanks to Modric Kristijan
<Kristijan.Modric@pliva.hr>
Mar/17/2003: - Release 1.4
--enable-sysconfdir - where the configuration directory is
Mar/09/2001: Sqmgrlog has gained a new name: SARG - Squid Analysis Report Generator.
- Many people have asked me about why sqmgrlog. I really don´t know.
+ Many people have asked me about why sqmgrlog. I really don�t know.
No inspiration I think.
SARG was suggested by an user from Philippines, but, I lost his email
- and don´t remember his name.
+ and don�t remember his name.
Thank you anyway.
MANDIR = @mandir@
SYSCONFDIR = @sysconfdir@
HTMLDIR = @HTMLDIR@
+LANGDIR = @LANGDIR@
+FONTDIR = @FONTDIR@
+IMAGEDIR = @IMAGEDIR@
ISYSCONFDIR = -DSYSCONFDIR=\"@sysconfdir@\"
IHTMLDIR = -DHTMLDIR=\"@HTMLDIR@\"
+ILANGDIR = -DLANGDIR=\"@LANGDIR@\"
+IFONTDIR = -DFONTDIR=\"@FONTDIR@\"
+IIMAGEDIR = -DIMAGEDIR=\"@IMAGEDIR@\"
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
all: sarg
.c.o:
- $(CC) -c -I. $(CPPFLAGS) $(DEFS) $(CFLAGS) $(IBINDIR) $(ISYSCONFDIR) $(IHTMLDIR) $<
+ $(CC) -c -I. $(CPPFLAGS) $(DEFS) $(CFLAGS) $(IBINDIR) $(ISYSCONFDIR) $(ILANGDIR) $(IFONTDIR) $(IIMAGEDIR) $(IHTMLDIR) $<
sarg: $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LIBS) $(LIBCRYPT)
echo "creating $(SYSCONFDIR)"; \
mkdir $(SYSCONFDIR); \
fi
- -@if test ! -d $(SYSCONFDIR)/languages; then \
- echo "Creating $(SYSCONFDIR)/languages"; \
- mkdir $(SYSCONFDIR)/languages; \
+ -@if test ! -d $(LANGDIR); then \
+ echo "Creating $(LANGDIR)"; \
+ mkdir -p $(LANGDIR); \
fi
- -@if test ! -d $(SYSCONFDIR)/fonts; then \
- echo "Creating $(SYSCONFDIR)/fonts"; \
- mkdir $(SYSCONFDIR)/fonts; \
+ -@if test ! -d $(FONTDIR); then \
+ echo "Creating $(FONTDIR)"; \
+ mkdir -p $(FONTDIR); \
+ fi
+ -@if test ! -d $(IMAGEDIR); then \
+ echo "Creating $(IMAGEDIR)"; \
+ mkdir -p $(IMAGEDIR); \
fi
$(INSTALL_PROGRAM) sarg $(BINDIR)/sarg
chmod 755 $(BINDIR)/sarg
else \
cp sarg.conf $(SYSCONFDIR)/sarg.conf.default; \
fi
- cp -r ./languages $(SYSCONFDIR);
+ cp -r ./languages/* $(LANGDIR);
cp ./exclude_codes $(SYSCONFDIR);
cp ./user_limit_block $(SYSCONFDIR);
- cp -r ./images $(SYSCONFDIR);
+ cp -r ./images/* $(IMAGEDIR);
cp -r ./sarg-php $(SYSCONFDIR);
- cp -r ./fonts $(SYSCONFDIR);
+ cp -r ./fonts/* $(FONTDIR);
cp -r ./css.tpl $(SYSCONFDIR);
-@if test -d $(HTMLDIR); then \
cp -r ./sarg-php $(HTMLDIR); \
1. run ./configure
- configure options: --enable-bindir=where sarg binary will be saved
- default: /usr/bin
+ configure options: --bindir=where sarg binary will be saved
+ default: /usr/local/bin
- --enable-sysconfdir - where the configuration directory is
- default: /usr/local/sarg
+ --sysconfdir - where the configuration directory is
+ default: /usr/local/etc
+
+ --mandir - where the sarg man page will be saved
+ default: /usr/local/share/man
--enable-htmldir - where the www html root dir is
default: /var/www/html
- --enable-mandir - where the sarg man page will be saved
- default: /usr/local/man/man1
+ --enable-languagedir - where the translation of sarg are
+ default: /usr/local/share/sarg/languages
+
+ --enable-fontdir - where to find the fonts for the reports
+ default: /usr/local/share/sarg/fonts
+
+ --enable-imagedir - where sarg take the images to include in the reports
+ default: /usr/local/share/sarg/images
3. make
--- /dev/null
+WHY SWITCH TO CMAKE
+
+I (Frederic Marchal) could not make the autotools work with msys+mingw. The choices reduced to: fight some more time with the autotools; wait until the msys port evolved or switch to cmake. Despite not being familiar with cmake, I decided to give it a chance and was surprised to come up within a few hours with something capable of compiling sarg.
+
+Now, that doesn't mean that the autotools are to be discarded on the spot. The two systems may coexist for some times especially since it is my first project with cmake and I'm sure it is done in an definitely autotoolistic way.
+
+
+CONFIGURING SARG
+
+It is recommended to build sarg out of the source directory. It makes it easier to delete the build directory completely and restart the configuration from scratch if the first attempt doesn't produce the expected result. To do so, create a directory at the same level as the sources of sarg and cd into that directory.
+
+Configure sarg with the command
+
+ ccmake ../sarg
+
+On the first run, it will report that the cache is empty. Press 'c' to configure the cache. Then ccmake will display an interface to select some configuration options. You should set the CMAKE_INSTALL_PREFIX to the root of the directory to install sarg, for instance: /usr. You may also need to change SYSCONFDIR to /etc/sarg to install the configuration files at that location.
+
+Then press 'c' again to reconfigure sarg. Four more configuration variables appear. They are build from the paths you provided for the installation directories of the components. These are the absolute paths sarg will use to find the corresponding files. You then have the opportunity to adjust them if the final location of the files it not what is resolved with the installed configuration.
+
+Finally, press 'g' to generate the final configuration.
+
+Compile with
+
+ make
+
+Install with
+
+ make install
+
+
+CONFIGURATION VARIABLES
+
+These configuration variables are available on the first configuration run.
+
+ CMAKE_INSTALL_PREFIX - The root of the installation.
+ defaut: /usr/local
+
+ SYSCONFDIR - The directory with the configuration files relative to the installation prefix.
+ default: etc/sarg
+
+ BINDIR - The directory to copy sarg executable to.
+ default: bin
+
+ MANDIR - The directory to install the man page.
+ default: share/man
+
+ LANGDIR - The directory to copy the languages files to.
+ default: share/sarg/languages
+
+ FONTDIR - The directory where the fonts for the reports are located.
+ default: share/sarg/fonts
+
+ IMAGEDIR - The directory containing the images to use in the reports.
+ default: share/sarg/images
+
+These variables are initialized with the values of the above variables and are available on the second run.
+
+ SYSCONFDIR_SOURCE - The full path to the configuration files to compile in sarg.
+ default: CMAKE_INSTALL_PREFIX/SYSCONFDIR
+
+ LANGDIR_SOURCE - The full path to the languages files to compile in sarg.
+ default: CMAKE_INSTALL_PREFIX/LANGDIR
+
+ FONTDIR_SOURCE - The full path to the fonts to compile in sarg.
+ default: CMAKE_INSTALL_PREFIX/FONTDIR
+
+ IMAGEDIR_SOURCE - The full path to the images to compile in sarg.
+ default: CMAKE_INSTALL_PREFIX/IMAGEDIR
+
+They are other configuration variables whose documentation is visible during the configuration with ccmake.
+
--- /dev/null
+/*
+Stub file that should be used when the program is not configured by cmake. If you use
+cmake to configure sarg, a config.h file will be created in ${CMAKE_BINARY_DIR} and should
+be used before this one.
+*/
ac_subst_vars='LTLIBOBJS
LIBOBJS
+IMAGEDIR
+FONTDIR
+LANGDIR
HTMLDIR
LTLIBICONV
LIBICONV
with_libiconv_prefix
enable_largefile
enable_htmldir
+enable_languagedir
+enable_fontdir
+enable_imagedir
'
ac_precious_vars='build_alias
host_alias
--disable-largefile omit support for large files
--enable-htmldir=htmldir
Select htmldir as the root of your WWW documents
+ --enable-languagedir=languagedir
+ Select languagedir as the directory with the translations of sarg
+ --enable-fontdir=fontdir
+ Select fontdir as the directory with the fonts to use in the reports
+ --enable-imagedir=imagedir
+ Select imagedir as the directory with the images to use in the reports
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
-LDFLAGS="-g"
-
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
{ { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
echo "using $HTMLDIR as the WWW Document Root dir"
+# Check whether --enable-languagedir was given.
+if test "${enable_languagedir+set}" = set; then
+ enableval=$enable_languagedir;
+ if test "$enableval"; then
+ LANGDIR=$enableval
+ fi
+
+else
+ LANGDIR="${datarootdir}/sarg/languages"
+fi
+
+echo "using $LANGDIR as the directory of the translations"
+
+
+# Check whether --enable-fontdir was given.
+if test "${enable_fontdir+set}" = set; then
+ enableval=$enable_fontdir;
+ if test "$enableval"; then
+ FONTDIR=$enableval
+ fi
+
+else
+ FONTDIR="${datarootdir}/sarg/fonts"
+fi
+
+echo "using $FONTDIR as the directory of the fonts"
+
+
+# Check whether --enable-imagedir was given.
+if test "${enable_imagedir+set}" = set; then
+ enableval=$enable_imagedir;
+ if test "$enableval"; then
+ IMAGEDIR=$enableval
+ fi
+
+else
+ IMAGEDIR="${datarootdir}/sarg/images"
+fi
+
+echo "using $IMAGEDIR as the directory of the images"
+
+
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
echo "using $HTMLDIR as the WWW Document Root dir"
AC_SUBST(HTMLDIR)
+dnl Select languages dir
+AC_ARG_ENABLE(languagedir,
+[ --enable-languagedir=languagedir
+ Select languagedir as the directory with the translations of sarg ],
+[
+ if test "$enableval"; then
+ LANGDIR=$enableval
+ fi
+],[LANGDIR="${datarootdir}/sarg/languages"])
+echo "using $LANGDIR as the directory of the translations"
+AC_SUBST(LANGDIR)
+
+dnl Select fonts dir
+AC_ARG_ENABLE(fontdir,
+[ --enable-fontdir=fontdir
+ Select fontdir as the directory with the fonts to use in the reports ],
+[
+ if test "$enableval"; then
+ FONTDIR=$enableval
+ fi
+],[FONTDIR="${datarootdir}/sarg/fonts"])
+echo "using $FONTDIR as the directory of the fonts"
+AC_SUBST(FONTDIR)
+
+dnl Select images dir
+AC_ARG_ENABLE(imagedir,
+[ --enable-imagedir=imagedir
+ Select imagedir as the directory with the images to use in the reports ],
+[
+ if test "$enableval"; then
+ IMAGEDIR=$enableval
+ fi
+],[IMAGEDIR="${datarootdir}/sarg/images"])
+echo "using $IMAGEDIR as the directory of the images"
+AC_SUBST(IMAGEDIR)
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
int silver;
int black;
int x1;
-//char *font1 = SYSCONFDIR"/fonts/FreeSans.ttf";
-char *font1 = SYSCONFDIR"/fonts/DejaVuSans.ttf";
+//char *font1 = FONTDIR"/FreeSans.ttf";
+char *font1 = FONTDIR"/DejaVuSans.ttf";
char s[15];
#if defined(HAVE_GD) && defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
-
+#include "config.h"
#include "info.h"
-#if HAVE_STDIO_H
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
-#if HAVE_STDLIB_H
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
-#if HAVE_STRING_H
+#ifdef HAVE_STRING_H
#include <string.h>
#endif
-#if HAVE_STRINGS_H
+#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-#if HAVE_TIME_H
+#ifdef HAVE_TIME_H
#include <time.h>
#endif
-#if HAVE_SYS_RESOURCE_H
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
-#if HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if HAVE_SYS_DIRENT_H && !HAVE_DIRENT_H
+#if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H)
#include <sys/dirent.h>
#endif
-#if HAVE_DIRENT_H
+#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
-#if HAVE_SYS_SOCKET_H
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
-#if HAVE_NETDB_H
+#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
-#if HAVE_TYPES_H
+#ifdef HAVE_TYPES_H
#include <types.h>
#endif
-#if HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
-#if HAVE_ARPA_INET_H
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-#if HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#if HAVE_CTYPE_H
+#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
-#if HAVE_ERRNO_H
+#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
-#if HAVE_SYS_WAIT_H
+#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
-#if HAVE_GD_H
+#ifdef HAVE_GD_H
#include <gd.h>
#define HAVE_GD
gdImagePtr im;
gdPoint points[4];
#endif
-#if HAVE_GDFONTL_H
+#ifdef HAVE_GDFONTL_H
#include <gdfontl.h>
#endif
-#if HAVE_GDFONTT_H
+#ifdef HAVE_GDFONTT_H
#include <gdfontt.h>
#endif
-#if HAVE_GDFONTS_H
+#ifdef HAVE_GDFONTS_H
#include <gdfonts.h>
#endif
-#if HAVE_GDFONTMB_H
+#ifdef HAVE_GDFONTMB_H
#include <gdfontmb.h>
#endif
-#if HAVE_GDFONTG_H
+#ifdef HAVE_GDFONTG_H
#include <gdfontg.h>
#endif
-#if HAVE_STDARG_H
+#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
-#if HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
-#if HAVE_LIMITS_H
+#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
-#if HAVE_FOPEN64
+#if defined(HAVE_FOPEN64)
#define _FILE_OFFSET_BITS 64
#define MY_FOPEN fopen64
#else
#define MY_FOPEN fopen
#endif
+#if !defined(HAVE_BZERO)
+#define bzero(mem,size) memset(mem,0,size)
+#endif
+
+#if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP)
+int mkstemps(char *template, int suffixlen);
+#define mkstemp(template) mkstemps(template,0)
+#endif
+
+#if defined(__MINGW32__)
+#define mkdir(p,m) _mkdir(p)
+
+#ifndef WIFEXITED
+ #define WIFEXITED(S) 1
+#endif
+
+#ifndef WEXITSTATUS
+ #define WEXITSTATUS(S) (S)
+#endif
+
+#endif /*__MINGW32__*/
#define MAXLEN 20000
long long int my_atoll (const char *nptr);
--- /dev/null
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define PACKAGE_NAME "@PACKAGE_NAME@"
+#define PACKAGE_VERSION "@PACKAGE_VERSION@"
+#define SYSCONFDIR "@SYSCONFDIR_SOURCE@"
+#define LANGDIR "@LANGDIR_SOURCE@"
+#define FONTDIR "@FONTDIR_SOURCE@"
+#define IMAGEDIR "@IMAGEDIR_SOURCE@"
+
+#cmakedefine HAVE_STDIO_H
+#cmakedefine HAVE_STDLIB_H
+#cmakedefine HAVE_STRING_H
+#cmakedefine HAVE_STRINGS_H
+#cmakedefine HAVE_SYS_TIME_H
+#cmakedefine HAVE_TIME_H
+#cmakedefine HAVE_UNISTD_H
+#cmakedefine HAVE_SYS_DIRENT_H
+#cmakedefine HAVE_DIRENT_H
+#cmakedefine HAVE_SYS_SOCKET_H
+#cmakedefine HAVE_NETDB_H
+#cmakedefine HAVE_ARPA_INET_H
+#cmakedefine HAVE_SYS_TYPES_H
+#cmakedefine HAVE_NETINET_H
+#cmakedefine HAVE_SYS_STAT_H
+#cmakedefine HAVE_CTYPE_H
+#cmakedefine HAVE_GD
+#cmakedefine HAVE_GD_H
+#cmakedefine HAVE_GDFONTL_H
+#cmakedefine HAVE_GDFONTT_H
+#cmakedefine HAVE_GDFONTS_H
+#cmakedefine HAVE_GDFONTMB_H
+#cmakedefine HAVE_GDFONTG_H
+#cmakedefine HAVE_ICONV_H
+#cmakedefine HAVE_ERRNO_H
+#cmakedefine HAVE_SYS_RESOURCE_H
+#cmakedefine HAVE_SYS_WAIT_H
+#cmakedefine HAVE_STDARG_H
+#cmakedefine HAVE_INTTYPES_H
+#cmakedefine HAVE_LIMITS_H
+#cmakedefine HAVE_WINDOWS_H
+#cmakedefine HAVE_WINSOCK_H
+
+#cmakedefine IBERTY_LIB
+
+#cmakedefine HAVE_BZERO
+#cmakedefine HAVE_MKSTEMP
+#cmakedefine HAVE_FOPEN64
+
+#define OFFSET_STRING @OFFSET_STRING@
+#define RLIM_STRING "@RLIM_STRING@"
+#define ICONV_CONST @ICONV_CONST@
+
+#endif /*CONFIG_H*/
-#define VERSION PACKAGE_VERSION" Sep-07-2009"
+#define VERSION PACKAGE_VERSION" Sep-12-2009"
#define PGM PACKAGE_NAME
#define URL "http://sarg.sourceforge.net"
char buf[MAXLEN];
int record=0;
- 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);
+ if (snprintf(lfile,sizeof(lfile),LANGDIR"/%s",language)>=sizeof(lfile)) {
+ fprintf(stderr, "SARG: (language) language name is too long: %s/%s\n",LANGDIR,language);
exit(1);
}
my_mkdir(arqtt);
sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind);
if(strlen(arqtt) > 255) {
- fprintf(stderr, "SARG: (report) output file name too long: %s\n",arqtt);
- exit(1);
+ arqtt[255]='\0';
}
if ((fp_tt = fopen(arqtt, "w")) == 0) {
fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt);
exit(1);
}
- sprintf(per2,"%s/images",SYSCONFDIR);
+ strcpy(per2,IMAGEDIR);
dirp = opendir(per2);
if(dirp==NULL) {