aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-16 19:50:18 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-16 19:50:18 +0300
commit0fd2682e113c400af6c43da72543bd75448e5be8 (patch)
tree9466f2887983571a85f05f1865e9b4990018764e
parentf2774fb0fa223c998492e69d67f1cd3137c30ec6 (diff)
downloadrspamd-0fd2682e113c400af6c43da72543bd75448e5be8.tar.gz
rspamd-0fd2682e113c400af6c43da72543bd75448e5be8.zip
* Prepare to migrate to cmake (still need to write install target and working with XS implicitly)
* Move all system includes to one file where we detect availability of all that includes * Fix license misprint * Fix some issues with perl initializing
-rw-r--r--CMakeLists.txt199
-rw-r--r--config.h.in185
-rwxr-xr-xconfigure1001
-rw-r--r--src/cfg_file.h10
-rw-r--r--src/cfg_file.l9
-rw-r--r--src/cfg_file.y23
-rw-r--r--src/cfg_utils.c22
-rw-r--r--src/classifiers/classifiers.c2
-rw-r--r--src/classifiers/classifiers.h5
-rw-r--r--src/classifiers/winnow.c4
-rw-r--r--src/controller.c21
-rw-r--r--src/filter.c2
-rw-r--r--src/filter.h8
-rw-r--r--src/fstring.c5
-rw-r--r--src/hash.c5
-rw-r--r--src/hash.h2
-rw-r--r--src/main.c22
-rw-r--r--src/main.h20
-rw-r--r--src/mem_pool.c48
-rw-r--r--src/mem_pool.h4
-rw-r--r--src/memcached-test.c2
-rw-r--r--src/memcached.c2
-rw-r--r--src/message.c18
-rw-r--r--src/message.h21
-rw-r--r--src/perl.c12
-rw-r--r--src/perl.h4
-rw-r--r--src/plugins/regexp.c14
-rw-r--r--src/plugins/surbl.c15
-rw-r--r--src/protocol.c6
-rw-r--r--src/statfile.c12
-rw-r--r--src/statfile.h6
-rw-r--r--src/tokenizers/osb.c2
-rw-r--r--src/tokenizers/tokenizers.c2
-rw-r--r--src/upstream.c2
-rw-r--r--src/url.c14
-rw-r--r--src/url.h10
-rw-r--r--src/util.c19
-rw-r--r--src/util.h17
-rw-r--r--src/worker.c29
39 files changed, 448 insertions, 1356 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..d61875813
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,199 @@
+#
+# Rspamd - rambler antispam system
+#
+# Cmake configuration file
+#
+PROJECT(rspamd C)
+
+SET(RSPAMD_VERSION_MAJOR 0)
+SET(RSPAMD_VERSION_MINOR 1)
+SET(RSPAMD_VERSION_PATCH 0)
+
+SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
+SET(RSPAMD_MASTER_SITE_URL "http://cebka.pp.ru/hg/rspamd")
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
+
+OPTION(DEBUG_MODE "Enable debug output [default: OFF]" OFF)
+OPTION(ENABLE_OPTIMIZATION "Enable optimization [default: ON]" ON)
+OPTION(SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" OFF)
+
+# Build optimized code for following CPU (default i386)
+#SET(CPU_TUNE "i686")
+
+# ################################################################################
+# Check Includes
+#
+INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckSymbolExists)
+INCLUDE(CheckLibraryExists)
+INCLUDE(FindPkgConfig)
+INCLUDE(FindPerl)
+
+IF(NOT PERL_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "Error: Perl is not found but is required")
+ENDIF(NOT PERL_EXECUTABLE)
+
+# Find perl libraries and cflags
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -MExtUtils::Embed -e ccopts OUTPUT_VARIABLE PERL_CFLAGS)
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -MExtUtils::Embed -e ldopts OUTPUT_VARIABLE PERL_LDFLAGS)
+STRING(REGEX REPLACE "[\r\n]" " " PERL_CFLAGS ${PERL_CFLAGS})
+STRING(REGEX REPLACE " +$" "" PERL_CFLAGS ${PERL_CFLAGS})
+STRING(REGEX REPLACE "[\r\n]" " " PERL_LDFLAGS ${PERL_LDFLAGS})
+STRING(REGEX REPLACE " +$" "" PERL_LDFLAGS ${PERL_LDFLAGS})
+
+# Lex and yacc
+FIND_PROGRAM(LEX_EXECUTABLE lex)
+FIND_PROGRAM(YACC_EXECUTABLE yacc)
+
+IF(NOT LEX_EXECUTABLE OR NOT YACC_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "Error: yacc and lex are required for build")
+ENDIF(NOT LEX_EXECUTABLE OR NOT YACC_EXECUTABLE)
+
+pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.10)
+pkg_check_modules(GMIME2 REQUIRED gmime-2.0)
+
+INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(${GMIME2_INCLUDE_DIRS})
+LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS})
+LINK_DIRECTORIES(${GMIME2_LIBRARY_DIRS})
+
+SET(CMAKE_REQUIRED_LIBRARIES m)
+SET(CMAKE_REQUIRED_INCLUDES sys/mman.h stdlib.h stdio.h unistd.h time.h sched.h)
+
+CHECK_LIBRARY_EXISTS(util pidfile_open " " HAVE_PIDFILE)
+CHECK_LIBRARY_EXISTS(event event_loop " " HAVE_LIBEVENT)
+IF(NOT HAVE_LIBEVENT)
+ MESSAGE(FATAL_ERROR "libevent is required for building rspamd")
+ENDIF(NOT HAVE_LIBEVENT)
+
+CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILES(sys/uio.h HAVE_SYS_UIO_H)
+
+CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
+CHECK_INCLUDE_FILES(math.h HAVE_MATH_H)
+CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
+CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
+CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
+CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
+CHECK_INCLUDE_FILES(time.h HAVE_TIME_H)
+CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILES(sysexits.h HAVE_SYSEXITS_H)
+CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
+CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H)
+CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
+CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
+CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
+CHECK_INCLUDE_FILES(sys/queue.h HAVE_SYS_QUEUE_H)
+CHECK_INCLUDE_FILES(sys/socket.h HAVE_SYS_SOCKET_H)
+CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN_H)
+CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN_H)
+CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H)
+CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H)
+CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H)
+CHECK_INCLUDE_FILES(syslog.h HAVE_SYSLOG_H)
+
+CHECK_FUNCTION_EXISTS(setproctitle HAVE_SETPROCTITLE)
+CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
+CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
+
+CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX)
+CHECK_SYMBOL_EXISTS(MAXPATHLEN sys/param.h HAVE_MAXPATHLEN)
+CHECK_SYMBOL_EXISTS(MAP_SHARED sys/mman.h HAVE_MMAP_SHARED)
+CHECK_SYMBOL_EXISTS(MAP_ANON sys/mman.h HAVE_MMAP_ANON)
+CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN)
+CHECK_SYMBOL_EXISTS(SLIST_FOREACH_SAFE sys/queue.h HAVE_COMPATIBLE_QUEUE_H)
+
+if (NOT HAVE_COMPATIBLE_QUEUE_H)
+ INCLUDE_DIRECTORIES(compat)
+endif (NOT HAVE_COMPATIBLE_QUEUE_H)
+
+
+SET(CONTRIBSRC "")
+FIND_PATH(MD5_INCLUDE md5.h PATHS /opt/include
+ /usr/include
+ /usr/local/include
+ DOC "Path where the openssl header files can be found")
+IF (MD5_INCLUDE)
+ INCLUDE_DIRECTORIES(${MD5_INCLUDE})
+
+ FIND_LIBRARY(MD5_LIBRARY NAMES md PATHS /lib
+ /opt/lib
+ /usr/lib
+ /usr/local/lib
+ DOC "Path where the md5 libraries can be found")
+ IF (MD5_LIBRARY)
+ SET(PROJECT_LIBS "${PROJECT_LIBS} md")
+ MESSAGE(STATUS "INFO: MD5 (libmd) hash function support enabled")
+ ELSE (MD5_LIBRARY)
+ MESSAGE(SEND_ERROR "ERROR: Cannot find libmd.so, aborting")
+ ENDIF (MD5_LIBRARY)
+ELSE (MD5_INCLUDE)
+ SET(CONTRIBSRC compat/md5.c)
+ MESSAGE(STATUS "WARNING: Using internal MD5 support")
+ENDIF (MD5_INCLUDE)
+
+IF("${CMAKE_COMPILER_IS_GNUC}" MATCHES "1")
+ SET(CMAKE_C_WARN_FLAGS " -Wall -W -Wpointer-arith -Wno-unused-parameter -Wno-unused-function -Wunused-variable -Wno-sign-compare -Wunused-value")
+
+ IF(DEBUG_MODE MATCHES "ON")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb ")
+ ENDIF(DEBUG_MODE MATCHES "ON")
+ENDIF("${CMAKE_COMPILER_IS_GNUC}" MATCHES "1")
+
+SET(RSPAMDSRC src/modules.c
+ src/hash.c
+ src/worker.c
+ src/util.c
+ src/url.c
+ src/upstream.c
+ src/statfile.c
+ src/protocol.c
+ src/perl.c
+ src/message.c
+ src/mem_pool.c
+ src/memcached.c
+ src/main.c
+ src/fstring.c
+ src/filter.c
+ src/controller.c
+ src/cfg_utils.c)
+
+SET(TOKENIZERSSRC src/tokenizers/tokenizers.c
+ src/tokenizers/osb.c)
+
+SET(CLASSIFIERSSRC src/classifiers/classifiers.c
+ src/classifiers/winnow.c)
+
+SET(PLUGINSSRC src/plugins/surbl.c
+ src/plugins/regexp.c)
+
+LIST(LENGTH PLUGINSSRC RSPAMD_MODULES_NUM)
+
+SET(YACC_SRC src/cfg_file.y)
+SET(LEX_SRC src/cfg_file.l)
+
+STRING(REPLACE "_file.y" "_yacc.c" YACC_OUTPUT ${YACC_SRC})
+STRING(REPLACE "_file.l" "_lex.c" LEX_OUTPUT ${LEX_SRC})
+
+ADD_CUSTOM_COMMAND(OUTPUT ${LEX_OUTPUT}
+ COMMAND ${LEX_EXECUTABLE} -o${LEX_OUTPUT} ${LEX_SRC})
+ADD_CUSTOM_COMMAND(OUTPUT ${YACC_OUTPUT}
+ COMMAND ${YACC_EXECUTABLE} -d -o ${YACC_OUTPUT} ${YACC_SRC})
+ADD_CUSTOM_COMMAND(TARGET perlxs PRE_LINK
+ COMMAND ${PERL_EXECUTABLE} ./Makefile.PL
+ COMMAND make
+ WORKING_DIRECTORY perl
+ VERBATIM)
+CONFIGURE_FILE(config.h.in src/config.h)
+ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CONTRIBSRC} ${TOKENIZERSSRC} ${CLASSIFIERSSRC} ${PLUGINSSRC} ${YACC_OUTPUT} ${LEX_OUTPUT})
+SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C)
+SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
+SET_TARGET_PROPERTIES(rspamd PROPERTIES COMPILE_FLAGS ${PERL_CFLAGS}
+ LINK_FLAGS ${PERL_LDFLAGS})
+TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES})
+TARGET_LINK_LIBRARIES(rspamd event)
+TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES})
diff --git a/config.h.in b/config.h.in
index 48c7bc129..a594e2109 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,4 +1,187 @@
+#ifndef RSPAMD_CONFIG_H_IN
+#define RSPAMD_CONFIG_H_IN
+
+#cmakedefine HAVE_SYS_TYPES_H 1
+
+#cmakedefine HAVE_SYS_TIME_H 1
+
+#cmakedefine HAVE_SYS_UIO_H 1
+
+#cmakedefine HAVE_FCNTL_H 1
+
+#cmakedefine HAVE_MATH_H 1
+
+#cmakedefine HAVE_STDIO_H 1
+
+#cmakedefine HAVE_STDLIB_H 1
+
+#cmakedefine HAVE_STRING_H 1
+
+#cmakedefine HAVE_STRINGS_H 1
+
+#cmakedefine HAVE_TIME_H 1
+
+#cmakedefine HAVE_UNISTD_H 1
+
+#cmakedefine HAVE_SYSEXITS_H 1
+
+#cmakedefine HAVE_STDINT_H 1
+
+#cmakedefine HAVE_INTTYPES_H 1
+
+#cmakedefine HAVE_STDBOOL_H 1
+
+#cmakedefine HAVE_NETDB_H 1
+
+#cmakedefine HAVE_SYSLOG_H 1
+
+#cmakedefine HAVE_ENDIAN_H 1
+#cmakedefine HAVE_SYS_ENDIAN_H 1
+#cmakedefine HAVE_MACHINE_ENDIAN_H 1
+
+#cmakedefine HAVE_SYS_QUEUE_H 1
+#cmakedefine HAVE_SYS_MMAN_H 1
+#cmakedefine HAVE_SYS_SOCKET_H 1
+#cmakedefine HAVE_SYS_UN_H 1
+
+#cmakedefine HAVE_SETPROCTITLE 1
+
+#cmakedefine HAVE_GETPAGESIZE 1
+
+#cmakedefine HAVE_NANOSLEEP 1
+
+#cmakedefine HAVE_PATH_MAX 1
+
+#cmakedefine HAVE_MAXPATHLEN 1
+
+#cmakedefine HAVE_MMAP_SHARED 1
+
+#cmakedefine HAVE_MMAP_ANON 1
+
+#cmakedefine HAVE_OWN_QUEUE_H 1
+
+#cmakedefine HAVE_SC_NPROCESSORS_ONLN 1
+
+#cmakedefine DEBUG_MODE 1
+
+#define RVERSION "${RSPAMD_VERSION}"
+#define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}"
+
+#define MODULES_NUM ${RSPAMD_MODULES_NUM}
+
+/* sys/types */
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
+
+/* stdint */
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
+
+/* stdbool */
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#endif
+
+/* queue */
+#ifdef HAVE_COMPATIBLE_QUEUE_H
+#ifdef HAVE_SYS_QUEUE_H
+#include <sys/queue.h>
+#endif
+#else
+#include "queue.h"
+#endif
+
+/* sys/socket */
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+/* sys/mman */
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+/* netinet issues */
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+/* unix sockets */
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+
+/* netdb */
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+/* stdlib */
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+/* stdio */
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+/* time */
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+
+/* sysexits */
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#endif
+
+/* unistd */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+
+/* string */
+#ifdef HAVE_STDIO_H
+#include <string.h>
+#endif
+
+/* fcntl */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+/* sys/stat */
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+/* math */
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+
+#include <errno.h>
+#include <signal.h>
+#include <event.h>
+#include <glib.h>
+#include <gmime/gmime.h>
/* Forwarded declaration */
struct module_ctx;
@@ -12,3 +195,5 @@ typedef struct module_s {
} module_t;
extern module_t modules[];
+
+#endif
diff --git a/configure b/configure
deleted file mode 100755
index 5861cadc3..000000000
--- a/configure
+++ /dev/null
@@ -1,1001 +0,0 @@
-#!/bin/sh
-
-GCC="gcc"
-MAKE=""
-LEX=""
-YACC=""
-OS=""
-
-PKG_CONFIG=`which pkg-config`
-PERL=`which perl`
-
-LOCALBASE=/usr/local
-PREFIX=$LOCALBASE
-
-VERSION=0.0.1
-COMPAT_DIR="./compat"
-
-YACC_SRC="cfg_file.y"
-LEX_SRC="cfg_file.l"
-YACC_OUTPUT="cfg_yacc.c"
-LEX_OUTPUT="cfg_lex.c"
-CONFIG="config.h"
-CACHE="config.cache"
-
-SRCDIR="src"
-OBJDIR="src/.obj"
-SOURCES="upstream.c cfg_utils.c memcached.c message.c hash.c main.c util.c controller.c worker.c fstring.c url.c perl.c protocol.c mem_pool.c filter.c plugins/regexp.c plugins/surbl.c tokenizers/tokenizers.c tokenizers/osb.c classifiers/classifiers.c classifiers/winnow.c statfile.c ${LEX_OUTPUT} ${YACC_OUTPUT}"
-MODULES="surbl regexp"
-
-CFLAGS="$CFLAGS -W -Wpointer-arith -Wno-unused-parameter"
-CFLAGS="$CFLAGS -Wno-unused-function -Wunused-variable -Wno-sign-compare"
-CFLAGS="$CFLAGS -Wunused-value -ggdb -I${LOCALBASE}/include"
-CFLAGS="$CFLAGS "
-LDFLAGS="$LDFLAGS -L/usr/lib -L${LOCALBASE}/lib"
-OPT_FLAGS="-O -pipe -fno-omit-frame-pointer"
-DEPS="$SRCDIR/config.h $SRCDIR/cfg_file.h $SRCDIR/memcached.h $SRCDIR/util.h $SRCDIR/main.h $SRCDIR/upstream.h $SRCDIR/fstring.h $SRCDIR/url.h $SRCDIR/perl.h $SRCDIR/mem_pool.h $SRCDIR/protocol.h $SRCDIR/filter.h $SRCDIR/${LEX_OUTPUT} $SRCDIR/${YACC_OUTPUT}"
-EXEC=rspamd
-USER=postfix
-GROUP=postfix
-INSTALL="/usr/bin/install -v"
-MKDIR="/usr/bin/install -v -d"
-MANPATH="${PREFIX}/share/man"
-SUBDIRS="test utils"
-
-MAKEFILE="Makefile"
-MAKEFILE_IN="Makefile.in"
-PERL_MAKEFILE="perl/Makefile.PL.in"
-PERLCFLAGS=""
-PERLLDFLAGS=""
-
-DEPENDS_FILE=".depends"
-OPTS=""
-
-TARGETS="${EXEC}"
-
-check_cache()
-{
- type=$1
- name=$2
-
- line=`fgrep "$type:$name" $CACHE 2>/dev/null`
- if [ $? -eq 0 ] ; then
- result=`echo $line | cut -d ':' -f 3`
- CACHED=`echo $line | cut -d ':' -f 4-`
- if [ "F$result" = "Fyes" ] ; then
- return 0
- elif [ "F$result" = "Fno" ] ; then
- return 1
- else
- return 2
- fi
- else
- return 3
- fi
-}
-
-write_cache()
-{
- type=$1
- name=$2
- result=$3
- value=$4
-
- echo "$type:$name:$result:$value" >> $CACHE
-}
-
-prepare_config()
-{
- echo "#ifndef CONFIG_H_IN" > $SRCDIR/$CONFIG
- echo "#define CONFIG_H_IN" >> $SRCDIR/$CONFIG
- cat "$CONFIG.in" >> $SRCDIR/$CONFIG
-}
-
-finish_config()
-{
- echo "#endif" >> $SRCDIR/$CONFIG
-}
-
-cleanup()
-{
- rm -f autotest.c
- rm -f autotest
- INCLUDE=""
-}
-
-have_opt()
-{
- echo "#define HAVE_$1" >> $SRCDIR/$CONFIG
- OPTS="$OPTS HAVE_$1"
-}
-
-check_compiler()
-{
- echo -n "Testing for gcc: "
- check_cache "compiler" "gcc"
- if [ $? -eq 0 ] ; then
- GCC=$CACHED
- echo "found(cached) -> $GCC"
- return 0
- fi
-
- GCC=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which gcc`
- if [ -x $GCC ] ; then
- echo "found -> $GCC"
- write_cache "compiler" "gcc" "yes" "$GCC"
- return 0
- else
- echo "not found"
- exit 1
- fi
-}
-
-check_make()
-{
- echo -n "Testing for make: "
- check_cache "make" "make"
- if [ $? -eq 0 ] ; then
- MAKE=$CACHED
- echo "found(cached) -> $MAKE"
- return 0
- fi
- MAKE=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which make`
- if [ -x $MAKE ] ; then
- echo "found -> $MAKE"
- write_cache "make" "make" "yes" "$MAKE"
- return 0
- else
- echo "not found"
- exit 1
- fi
-
-}
-
-check_lex()
-{
- echo -n "Testing for lex: "
- check_cache "binary" "lex"
- if [ $? -eq 0 ] ; then
- LEX=$CACHED
- echo "found(cached) -> $LEX"
- return 0
- fi
-
- LEX=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which lex`
- if [ -x $LEX ] ; then
- echo "found -> $LEX"
- write_cache "binary" "lex" "yes" "$LEX"
- return 0
- else
- echo "not found"
- exit 1
- fi
-
-}
-
-check_yacc()
-{
- echo -n "Testing for yacc: "
- check_cache "binary" "yacc"
- if [ $? -eq 0 ] ; then
- YACC=$CACHED
- echo "found(cached) -> $YACC"
- return 0
- fi
-
- YACC=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which yacc`
- echo -n "Testing for yacc: "
- if [ -x $YACC ] ; then
- echo "found -> $YACC"
- write_cache "binary" "yacc" "yes" "$YACC"
- return 0
- else
- echo "not found"
- exit 1
- fi
-
-}
-
-check_util()
-{
- echo -n "Testing for $1: "
- check_cache "binary" "$1"
- if [ $? -eq 0 ] ; then
- echo "found(cached) -> $CACHED"
- return 0
- fi
- UTIL=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which $1`
- if [ -x $UTIL ] ; then
- echo "found -> $UTIL"
- write_cache "binary" "$1" "yes" "$UTIL"
- return 0
- else
- echo "not found"
- exit 1
- fi
-
-}
-
-check_function()
-{
- FUNCTION=$1
- while [ $# -ne 0 -a -n $2 ] ; do
- shift
- if [ "F$INCLUDE" = "F" ] ; then
- INCLUDE="$1"
- else
- INCLUDE="$INCLUDE $1"
- fi
- done
- echo -n "Testing for $FUNCTION: "
- echo >> config.log
- echo "Testing for $FUNCTION: " >> config.log
- check_cache "function" "$FUNCTION"
- if [ $? -eq 0 ] ; then
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- return 0
- fi
- echo "#include <sys/types.h>" > autotest.c
- if [ "F$INCLUDE" != "F" ] ; then
- for inc in $INCLUDE ; do
- echo "#include \"$inc\"" >> autotest.c
- done
- fi
- echo "#include <stdlib.h>" >> autotest.c
- echo "int main (int argc, char **argv) { $FUNCTION; return 0; }" >> autotest.c
- echo "$GCC $PTHREAD_CFLAGS $CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >>config.log
- $GCC $PTHREAD_CFLAGS $CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- cleanup
- echo "-> OK" >> config.log
- write_cache "function" "$FUNCTION" "yes" ""
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- cleanup
- write_cache "function" "$FUNCTION" "no" ""
- return 1
- fi
-}
-
-check_include()
-{
- _INCLUDE="$1"
- echo -n "Testing for $_INCLUDE: "
- echo >> config.log
- echo "Testing for $_INCLUDE: " >> config.log
- check_cache "include" "$_INCLUDE"
- if [ $? -eq 0 ] ; then
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- have_opt $CACHED
- return 0
- fi
- echo "#include <sys/types.h>" > autotest.c
- echo "#include \"$_INCLUDE\"" >> autotest.c
- echo "#include <stdlib.h>" >> autotest.c
- echo "int main (int argc, char **argv) { return 0; }" >> autotest.c
- echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >>config.log
- $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- echo "-> OK" >> config.log
- _CFLAG=`echo "$_INCLUDE" | sed -e 's/[./]/_/g' | tr '[:lower:]' '[:upper:]'`
- have_opt $_CFLAG
- write_cache "include" "$_INCLUDE" "yes" "$_CFLAG"
- cleanup
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- write_cache "include" "$_INCLUDE" "no" ""
- cleanup
- return 1
- fi
-}
-
-check_macro()
-{
- MACRO=$1
- _INCLUDE=""
- while [ $# -ne 1 -a -n $1 ] ; do
- shift
- if [ "F$_INCLUDE" = "F" ] ; then
- _INCLUDE="$1"
- else
- _INCLUDE="$_INCLUDE $1"
- fi
- done
- echo -n "Testing for $MACRO: "
- echo >> config.log
- echo "Testing for $MACRO: " >> config.log
- check_cache "macro" "$MACRO"
- if [ $? -eq 0 ] ; then
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- return 0
- fi
- echo "#include <sys/types.h>" > autotest.c
- for _inc in $_INCLUDE ; do
- echo "#include \"$_inc\"" >> autotest.c
- done
- echo "#include <stdlib.h>" >> autotest.c
- echo "int main (int argc, char **argv) {" >>autotest.c
- echo "#ifndef $MACRO" >>autotest.c
- echo "#error \"$MACRO not defined\"" >>autotest.c
- echo "#endif" >> autotest.c
- echo "}" >>autotest.c
- echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >> config.log
- $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- echo "-> OK" >> config.log
- write_cache "macro" "$MACRO" "yes" ""
- cleanup
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- write_cache "macro" "$MACRO" "no" ""
- cleanup
- return 1
- fi
-}
-
-
-check_lib()
-{
- LIB=$1
- while [ $# -ne 1 -a -n $1 ] ; do
- shift
- if [ "F$INCLUDE" = "F" ] ; then
- INCLUDE="$1"
- else
- INCLUDE="$INCLUDE $1"
- fi
- done
- echo -n "Testing for lib$LIB: "
- echo >> config.log
- echo "Testing for lib$LIB: " >> config.log
- check_cache "lib" "$LIB"
- if [ $? -eq 0 ] ; then
- LIBS="$LIBS -l$LIB"
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- return 0
- fi
- echo "#include <sys/types.h>" > autotest.c
- if [ "F$INCLUDE" != "F" ] ; then
- for inc in $INCLUDE ; do
- echo "#include \"$inc\"" >> autotest.c
- done
- fi
- echo "#include <stdlib.h>" >> autotest.c
- echo "int main (int argc, char **argv) { return 0; }" >> autotest.c
- echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS -l$LIB $PTHREAD_LDFLAGS autotest.c" >>config.log
- $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS -l$LIB $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- LIBS="$LIBS -l$LIB"
- echo "-> OK" >> config.log
- write_cache "lib" "$LIB" "yes" ""
- cleanup
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- write_cache "lib" "$LIB" "no" ""
- cleanup
- return 1
- fi
-}
-
-check_package()
-{
- PACKAGE=$1
- PLIBS=`$PKG_CONFIG --libs $PACKAGE`
- PCFLAGS=`$PKG_CONFIG --cflags $PACKAGE`
- while [ $# -ne 1 -a -n $1 ] ; do
- shift
- if [ "F$INCLUDE" = "F" ] ; then
- INCLUDE="$1"
- else
- INCLUDE="$INCLUDE $1"
- fi
- done
- echo -n "Testing for $PACKAGE: "
- echo >> config.log
- echo "Testing for $PACKAGE: " >> config.log
- check_cache "package" "$PACKAGE"
- if [ $? -eq 0 ] ; then
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- _p_cflags=`echo $CACHED | cut -d ':' -f 1`
- _p_libs=`echo $CACHED | cut -d ':' -f 2`
- LIBS="$LIBS $_p_libs"
- CFLAGS="$CFLAGS $_p_cflags"
- return 0
- fi
- echo "#include <sys/types.h>" > autotest.c
- if [ "F$INCLUDE" != "F" ] ; then
- for inc in $INCLUDE ; do
- echo "#include \"$inc\"" >> autotest.c
- done
- fi
- echo "#include <stdlib.h>" >> autotest.c
- echo "int main (int argc, char **argv) { return 0; }" >> autotest.c
- echo "$GCC $CFLAGS $PCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PLIBS $PTHREAD_LDFLAGS autotest.c" >>config.log
- $GCC $CFLAGS $PCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PLIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- LIBS="$LIBS $PLIBS"
- CFLAGS="$CFLAGS $PCFLAGS"
- echo "-> OK" >> config.log
- write_cache "package" "$PACKAGE" "yes" "$PCFLAGS:$PLIBS"
- cleanup
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- write_cache "package" "$PACKAGE" "no" ""
- cleanup
- return 1
- fi
-
-}
-
-check_perl()
-{
- echo -n "Testing for $PERL: "
- echo >> config.log
- echo "Testing for $PERL: " >> config.log
- check_cache "perl" "$PERL"
- if [ $? -eq 0 ] ; then
- echo "-> OK (cached)"
- echo "-> OK (cached)" >> config.log
- _p_cflags=`echo $CACHED | cut -d ':' -f 1`
- _p_libs=`echo $CACHED | cut -d ':' -f 2`
- PERLLDFLAGS="$LIBS $_p_libs"
- PERLCFLAGS="$CFLAGS $_p_cflags"
- return 0
- fi
-
- if [ ! -x $PERL ] ; then
- echo "not found"
- echo "-> FAILED" >> config.log
- cleanup
- return 1
- fi
- PERLCFLAGS=`$PERL -MExtUtils::Embed -e ccopts`
- PERLLDFLAGS=`$PERL -MExtUtils::Embed -e ldopts`
-
- echo "#include <stdlib.h>" > autotest.c
- echo "#include <EXTERN.h>" >> autotest.c
- echo "#include <perl.h>" >> autotest.c
- echo "int main (int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); return 0; }" >> autotest.c
- echo "$GCC $CFLAGS $PERLCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PERLLDFLAGS $PTHREAD_LDFLAGS autotest.c" >>config.log
- $GCC $CFLAGS $PERLCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PERLLDFLAGS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- echo "-> OK" >> config.log
- cleanup
- write_cache "perl" "$PERL" "yes" "$PERLCFLAGS:$PERLLDFLAGS"
- return 0
- else
- echo "not found"
- echo "-> FAILED" >> config.log
- echo "Failed program was:" >> config.log
- cat autotest.c >> config.log
- write_cache "perl" "$PERL" "no" ""
- cleanup
- return 1
- fi
-
-}
-
-check_os()
-{
- _OS=`uname -s`
- case "$_OS" in
- FreeBSD*)
- OS="freebsd"
- CFLAGS="${CFLAGS}"
- INSTALL="/usr/bin/install -C -S -v"
- MKDIR="/usr/bin/install -d -v"
- MANPATH="${PREFIX}/man"
- echo "#define FREEBSD" >> $SRCDIR/$CONFIG ;;
- Linux*) OS="linux" CFLAGS="${CFLAGS} -D_GNU_SOURCE"
- echo "#define LINUX" >> $SRCDIR/$CONFIG ;;
- Solaris*) OS="solaris" CFLAGS="${CFLAGS}"
- echo "#define SOLARIS" >> $SRCDIR/$CONFIG ;;
- *) OS="unknown" ;;
- esac
-}
-
-check_user()
-{
- _user=$1
- echo -n "Checking for user $_user: "
- grep $_user /etc/passwd > /dev/null 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- return 0
- else
- echo "not found"
- return 1
- fi
-}
-
-check_group()
-{
- _group=$1
- echo -n "Checking for group $_group: "
- grep $_group /etc/group > /dev/null 2>&1
- if [ $? -eq 0 ] ; then
- echo "found"
- return 0
- else
- echo "not found"
- return 1
- fi
-}
-
-check_depends()
-{
- ifdep=""
- depends=""
- if [ ! -f $DEPENDS_FILE ] ; then
- return 0
- fi
-
- while read line ; do
- echo $line | grep '#if' > /dev/null
- if [ $? -eq 0 ] ; then
- ifdep=`echo $line | sed -e 's/^#if \([A-Za-z0-9_]*\)$/\1/'`
- elif [ "F$ifdep" != "F" ] ; then
- echo $line | grep "#endif" > /dev/null
- if [ $? -eq 0 ] ; then
- ifdep=""
- else
- echo $OPTS | grep $ifdep > /dev/null
- if [ $? -eq 0 ] ; then
- depends="$depends $line"
- fi
- fi
- else
- depends="$depends $line"
- fi
- done < $DEPENDS_FILE
-
- obj_depends=`echo $depends | sed -e 's/\([^ ]\{1,\}\)\/\([^/]\{1,\}\).c/\2.o/g'`
- echo "DEPENDS=$depends" >> $MAKEFILE
- echo "OBJ_DEPENDS=$obj_depends" >> $MAKEFILE
- for _dep in $depends ; do
- _obj_dep=`echo $_dep | sed -e 's/\([^ ]\{1,\}\)\/\([^/]\{1,\}\).c/\2.o/g'`
- cat >> $MAKEFILE.dep << END
-${_obj_dep}: ${_dep}
- \$(CC) \$(OPT_FLAGS) \$(CFLAGS) \$(PTHREAD_CFLAGS) -o ${_obj_dep} -c ${_dep}
-
-END
-
- done
-}
-
-write_modules()
-{
- # Write modules init function
- echo "#ifndef MODULES_H" > $SRCDIR/modules.h
- echo "#include \"config.h\"" >> $SRCDIR/modules.h
- echo "#include \"modules.h\"" > $SRCDIR/modules.c
- echo "module_t modules[] = {" >> $SRCDIR/modules.c;
- modules_num=0
- for m in $MODULES ; do
- echo "{\"${m}\", ${m}_module_init, ${m}_module_config, ${m}_module_reconfig}," >> $SRCDIR/modules.c
- echo "int ${m}_module_init(struct config_file *cfg, struct module_ctx **ctx);" >> $SRCDIR/modules.h
- echo "int ${m}_module_config(struct config_file *cfg);" >> $SRCDIR/modules.h
- echo "int ${m}_module_reconfig(struct config_file *cfg);" >> $SRCDIR/modules.h
- modules_num=`expr $modules_num + 1`
- done
- echo "};" >> $SRCDIR/modules.c
- echo "#endif" >> $SRCDIR/modules.h
- echo "#define MODULES_NUM $modules_num" >> $SRCDIR/$CONFIG
- SOURCES="$SOURCES modules.c"
-
-}
-
-write_perl()
-{
- # Write to perl Makefile
- sed -e "s|%%libs%%|${LDFLAGS} ${LIBS}|" < $PERL_MAKEFILE > .pl_tmp
- sed -e "s|%%include%%|${CFLAGS}|" < .pl_tmp > .pl2_tmp
- PERL_MAKEFILE=`echo ${PERL_MAKEFILE} | sed -e 's|.in$||'`
- mv .pl2_tmp $PERL_MAKEFILE
- rm -f .pl_tmp .pl2_tmp
- CURDIR=`pwd`
- cd `dirname ${PERL_MAKEFILE}`
- $PERL Makefile.PL
- cd $CURDIR
-}
-
-write_subdirs()
-{
- # Write subdirs makefiles
- clean_target="clean-subdirs: "
- dist_clean_target="dist-clean-subdirs: "
- for sub in $SUBDIRS ; do
- cp $MAKEFILE $sub/$MAKEFILE
- saved_pwd=`pwd`
- old_objs=`echo $OBJECTS | sed -e 's/\([^. ]*\.o\)/..\/%%OBJDIR%%\/\1/g' | sed -e "s,%%OBJDIR%%,${OBJDIR},g"`
- old_srcs=`echo $SOURCES | sed -e 's/\([^. ]*\.c\)/..\/%%SRCDIR%%\/\1/g' | sed -e "s,%%SRCDIR%%,${SRCDIR},g"`
- cd $sub
- sub_src="`echo *.c`"
- sub_obj="`echo $sub_src | sed -e 's/\.c/\.o/g'`"
- echo "SOURCES=$sub_src" >> $MAKEFILE
- echo "OBJECTS=$sub_obj" >> $MAKEFILE
- check_depends
- cat Makefile.in >> $MAKEFILE
- if [ -f $MAKEFILE.dep ] ; then
- cat $MAKEFILE.dep >> $MAKEFILE
- rm -f $MAKEFILE.dep
- fi
- for _sub_src in $sub_src ; do
- _sub_obj=`echo $_sub_src | sed -e 's/\.c/\.o/g'`
- cat >> $MAKEFILE << END
-${_sub_obj}: ${_sub_src}
- \$(CC) \$(OPT_FLAGS) \$(CFLAGS) \$(PTHREAD_CFLAGS) -o ${_sub_obj} -c ${_sub_src}
-
-END
- done
- cd $saved_pwd
- dist_clean_target="$dist_clean_target ${sub}-dist-clean"
- clean_target="$clean_target ${sub}-clean"
- done
-
- # Write IN file
- cat $MAKEFILE_IN >> $MAKEFILE
-
- # Process clean targets for all subdirs
- echo $dist_clean_target >> $MAKEFILE
- echo $clean_target >> $MAKEFILE
- for sub in $SUBDIRS ; do
- cat >> $MAKEFILE << END
-${sub}-clean:
- cd ${sub} && make clean && cd ..
-${sub}-dist-clean:
- cd ${sub} && make dist-clean && cd ..
-${sub}:
- cd ${sub} && make && cd ..
-
-END
- done
-}
-
-write_result()
-{
- echo "Compiler: $GCC" >> config.log
- echo "Make: $MAKE" >> config.log
- echo "Sources: $SOURCES" >> config.log
- echo "Cflags: $CFLAGS" >> config.log
- echo "Ldflags: $LDFLAGS" >> config.log
- echo "Libs: $LIBS" >> config.log
- echo "#define RVERSION \"${VERSION}\"" >> $SRCDIR/$CONFIG
- echo "#define HASH_COMPAT" >> $SRCDIR/$CONFIG
-
- write_modules
- for _s in $SOURCES ; do
- _o=`echo $_s | awk -F '/' '{split($NF, A, "."); print "%%OBJDIR%%/"A[1]".o"}' | sed -e "s,%%OBJDIR%%,${OBJDIR},"`
- OBJECTS="$OBJECTS $_o"
- SRC_OBJ="$SRC_OBJ $_s#$_o"
- done
- write_perl
- # Make CFLAGS more readable
- CFLAGS="$CFLAGS $PERLCFLAGS"
- LIBS="$LIBS $PERLLDFLAGS"
- CFLAGS=`echo $CFLAGS | tr [:space:] \\\n | sed -e 's/$/ \\\/' | sed -e '$,$s/\\\//' | sort -r -k2 | uniq`
- LDFLAGS=`echo $LDFLAGS | tr [:space:] \\\n | sed -e 's/$/ \\\/' | sed -e '$,$s/\\\//' | sort -r -k2 | uniq`
- LIBS=`echo $LIBS | tr [:space:] \\\n | sed -e 's/$/ \\\/' | sed -e '$,$s/\\\//' | sort -r -k2 | uniq`
- cat > $MAKEFILE << END
-# This is ${EXEC} Makefile
-# For options edit Makefile.in, this file is autogenerated by configure
-
-CC=$GCC
-# Optimization flags
-OPT_FLAGS=$OPT_FLAGS
-# Compile time flags
-CFLAGS=$CFLAGS
-# Link time flags
-LDFLAGS=$LDFLAGS
-# Libraries to link
-LIBS=$LIBS
-# Directories for sources and objects
-SRCDIR=$SRCDIR
-OBJDIR=$OBJDIR
-# ${EXEC} sources
-SOURCES=$SOURCES
-# ${EXEC} objects
-OBJECTS=$OBJECTS
-# Version of product
-VERSION=$VERSION
-# Detected operation system
-OS=$OS
-# Lex and yacc executables
-LEX=$LEX
-YACC=$YACC
-# Pthread specific flags
-PTHREAD_CFLAGS=$PTHREAD_CFLAGS
-PTHREAD_LDFLAGS=$PTHREAD_LDFLAGS
-# Prefix to install
-PREFIX=$PREFIX
-# Where local libs and includes are located
-LOCALBASE=$LOCALBASE
-# Install commands
-INSTALL=$INSTALL
-MKDIR=$MKDIR
-# Executable name
-EXEC=$EXEC
-# User and group
-RSPAMD_USER=$USER
-RSPAMD_GROUP=$GROUP
-# All target dependenses
-TARGETS=$TARGETS $SUBDIRS
-# Common dependenses
-DEPS=$DEPS
-# Path to install manual page
-MANPATH=$MANPATH
-# Subdirectories
-SUBDIRS=$SUBDIRS
-
-END
-
- write_subdirs
-
- # Write build targets to makefile
- cat >> $MAKEFILE << END
-${EXEC}: \$(OBJECTS)
- \$(CC) \$(PTHREAD_LDFLAGS) \$(LDFLAGS) \$(OBJECTS) \$(LIBS) -o \$(EXEC)
-END
- for o in $SRC_OBJ ; do
- SO=`echo $o | cut -d '#' -f 1`
- O=`echo $o | cut -d '#' -f 2`
- cat >> $MAKEFILE << END
-${O}: \$(DEPS) ${SRCDIR}/${SO}
- \$(CC) \$(OPT_FLAGS) \$(CFLAGS) \$(PTHREAD_CFLAGS) -o ${O} -c ${SRCDIR}/${SO}
-
-END
- done
- cat >> $MAKEFILE << END
-${SRCDIR}/${LEX_OUTPUT}: \$(SRCDIR)/cfg_file.h \$(SRCDIR)/${LEX_SRC} \$(SRCDIR)/${YACC_OUTPUT}
- \$(LEX) -o\$(SRCDIR)/${LEX_OUTPUT} \$(SRCDIR)/${LEX_SRC}
-
-${SRCDIR}/${YACC_OUTPUT}: \$(SRCDIR)/cfg_file.h \$(SRCDIR)/${YACC_SRC}
- \$(YACC) -d -o \$(SRCDIR)/${YACC_OUTPUT} \$(SRCDIR)/${YACC_SRC}
-END
-}
-
-
-for option
-do
- case "$option" in
- -*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
- *) value="" ;;
- esac
-
- case "$option" in
- --help) help=yes ;;
- --prefix) PREFIX=$value ;;
- --user) USER=$value ;;
- --group) GROUP=$value ;;
- --enable-debug) CFLAGS="$CFLAGS -DWITH_DEBUG" OPT_FLAGS="" ;;
- --enable-opt) OPT_FLAGS="-O3 -pipe" ;;
- --add-module) SOURCES="$SOURCES $value"
- if [ ! -f $value ] ; then
- echo "Cannot find $value, please check path"
- exit 1
- fi
- modline=`grep '/***MODULE:' $value`
- if [ F"$modline" = "F" ] ; then
- echo "Cannot find /***MODULE line in $value, please check syntax"
- exit 1
- fi
-
- name=`echo $modline | sed 's/.*MODULE:\([^: ]*\).*/\1/'`
- MODULES="$MODULES $name" ;;
- --disable-module) SOURCES=`echo $SOURCES | sed -e "s/${value}//g"`
- if [ ! -f $value ] ; then
- echo "Cannot find $value, please check path"
- exit 1
- fi
- modline=`grep '/***MODULE:' $value`
- if [ F"$modline" = "F" ] ; then
- echo "Cannot find /***MODULE line in $value, please check syntax"
- exit 1
- fi
-
- name=`echo $modline | sed 's/.*MODULE:\([^: ]*\).*/\1/'`
- MODULES=`echo $MODULES | sed -e "s/${name}//g"` ;;
- *)
- echo "$0: error: invalid option \"$option\""
- exit 1
- ;;
- esac
-done
-
-if [ "F$help" = "Fyes" ] ; then
- cat << END
-
- --help this message
-
- --prefix=PATH set the installation prefix
- --enable-debug turn on extra debug messages
- --enable-opt turn on extra optimization
- --add-module add additional C module
- --disable-module do not include C module
- --user=USER set user to use
- --group=GROUP set group to use
-END
- exit 1
-fi
-
-CFLAGS="$CFLAGS -I$PREFIX/include"
-LDFLAGS="$LDFLAGS -L$PREFIX/lib"
-
-echo "Starting configure for rmilter" >config.log
-echo $0 $@ >> config.log
-
-prepare_config
-check_compiler
-check_make
-check_lex
-check_yacc
-check_util "sed"
-check_util "awk"
-check_util "cut"
-check_os
-
-check_lib "event" "event.h"
-if [ $? -eq 1 ] ; then
- echo "Libevent not found, check config.log for details"
- exit 1
-fi
-
-check_lib "m"
-check_lib "md"
-if [ $? -eq 1 ] ; then
- cp $COMPAT_DIR/md5.c $SRCDIR
- cp $COMPAT_DIR/md5.h $SRCDIR
- SOURCES="$SOURCES md5.c"
- DEPS="$DEPS $SRCDIR/md5.h"
- have_opt "OWN_MD5"
-fi
-
-check_lib "util"
-if [ $? -eq 0 ] ; then
- have_opt "LIBUTIL"
-fi
-
-check_function "pidfile_open" "sys/param.h" "libutil.h"
-if [ $? -eq 0 ] ; then
- have_opt "PIDFILE"
-fi
-
-check_function "bzero" "string.h"
-check_function "srandomdev"
-if [ $? -eq 0 ] ; then
- have_opt "SRANDOMDEV"
-fi
-
-check_function "sched_yield" "sched.h"
-if [ $? -eq 0 ] ; then
- have_opt "SCHED_YIELD"
-fi
-
-check_function "nanosleep" "time.h"
-if [ $? -eq 0 ] ; then
- have_opt "NANOSLEEP"
-fi
-
-
-check_function "getpagesize" "unistd.h"
-if [ $? -eq 0 ] ; then
- have_opt "GETPAGESIZE"
-fi
-
-check_function "setproctitle" "unistd.h"
-if [ $? -eq 0 ] ; then
- have_opt "SETPROCTITLE"
-fi
-
-check_include "endian.h"
-check_include "libutil.h"
-check_include "machine/endian.h"
-check_include "sys/time.h"
-check_include "time.h"
-check_include "stdint.h"
-if [ $? -eq 1 ] ; then
- check_include "inttypes.h"
-fi
-check_include "md5.h"
-check_include "sys/queue.h"
-if [ $? -eq 1 ] ; then
- cp $COMPAT_DIR/queue.h $SRCDIR
- DEPS="$DEPS $SRCDIR/queue.h"
-fi
-check_macro "SLIST_FOREACH_SAFE" "sys/queue.h"
-if [ $? -eq 1 ] ; then
- cp $COMPAT_DIR/queue.h $SRCDIR
- DEPS="$DEPS $SRCDIR/queue.h"
- have_opt "OWN_QUEUE_H"
-fi
-
-check_macro "PATH_MAX" "limits.h"
-if [ $? -eq 1 ] ; then
- check_macro "MAXPATHLEN" "sys/param.h"
- if [ $? -eq 1 ] ; then
- have_opt "MAXPATHLEN"
- echo "#define MAXPATHLEN 4096" >> $SRCDIR/$CONFIG
- else
- have_opt "MAXPATHLEN"
- fi
-else
- have_opt "PATH_MAX"
-fi
-
-check_macro "MAP_SHARED" "sys/mman.h"
-if [ $? -eq 1 ] ; then
- echo "Shared memory extension to mmap not found, this platform is not supported"
- exit 1
-fi
-
-check_macro "MAP_ANON" "sys/mman.h"
-if [ $? -eq 0 ] ; then
- have_opt "MMAP_ANON"
-else
- if [ -f "/dev/zero" ] ; then
- have_opt "MMAP_ZERO"
- else
- echo "Anon memory extension to mmap not found and /dev/zero not exists, this platform is not supported"
- exit 1
- fi
-fi
-
-check_macro "_SC_NPROCESSORS_ONLN" "unistd.h"
-if [ $? -eq 0 ] ; then
- have_opt "SC_NPROCESSORS_ONLN"
-fi
-
-check_package "glib-2.0" "glib.h"
-check_package "gmime-2.0" "gmime/gmime.h"
-if [ $? -eq 1 ] ; then
- echo "Package gmime-2.0 not found, check config.log for details"
- exit 1
-fi
-
-check_perl
-if [ $? -eq 1 ] ; then
- echo "Perl or libperl not found, check config.log for details"
- exit 1
-fi
-
-check_group $GROUP
-if [ $? -ne 0 ] ; then
- TARGETS="$TARGETS creategroup"
-fi
-check_user $USER
-if [ $? -ne 0 ] ; then
- TARGETS="$TARGETS createuser"
-fi
-write_result
-finish_config
diff --git a/src/cfg_file.h b/src/cfg_file.h
index a7ad3eaaf..a5d092c73 100644
--- a/src/cfg_file.h
+++ b/src/cfg_file.h
@@ -7,16 +7,6 @@
#define CFG_FILE_H
#include "config.h"
-#include <sys/types.h>
-#ifndef HAVE_OWN_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "queue.h"
-#endif
-#include <netinet/in.h>
-#include <sys/un.h>
-#include <event.h>
-#include <glib.h>
#include "mem_pool.h"
#include "upstream.h"
#include "memcached.h"
diff --git a/src/cfg_file.l b/src/cfg_file.l
index 7d940099f..c7ef97d18 100644
--- a/src/cfg_file.l
+++ b/src/cfg_file.l
@@ -2,11 +2,8 @@
%x module
%{
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <syslog.h>
+
+#include "config.h"
#include "cfg_file.h"
#include "cfg_yacc.h"
@@ -95,7 +92,7 @@ yes|YES|no|NO|[yY]|[nN] yylval.flag=parse_flag(yytext); return FLAG;
[a-zA-Z0-9.-]+:[0-9]{1,5} yylval.string=strdup(yytext); return HOSTPORT;
[a-zA-Z<][a-zA-Z@+>_-]* yylval.string=strdup(yytext); return STRING;
\/[^/\n]+\/ yylval.string=strdup(yytext); return REGEXP;
-[a-zA-Z0-9].[a-zA-Z0-9\/.-]+ yylval.string=strdup(yytext); return DOMAIN;
+[a-zA-Z0-9].[a-zA-Z0-9\/.-]+ yylval.string=strdup(yytext); return DOMAINNAME;
<incl>[ \t]* /* eat the whitespace */
<incl>[^ \t\n]+ { /* got the include file name */
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) {
diff --git a/src/cfg_file.y b/src/cfg_file.y
index e842c560e..73455976d 100644
--- a/src/cfg_file.y
+++ b/src/cfg_file.y
@@ -2,20 +2,7 @@
%{
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <glib.h>
-
+#include "config.h"
#include "cfg_file.h"
#include "main.h"
#include "classifiers/classifiers.h"
@@ -45,7 +32,7 @@ struct statfile *cur_statfile = NULL;
%token ERROR STRING QUOTEDSTRING FLAG
%token FILENAME REGEXP QUOTE SEMICOLON OBRACE EBRACE COMMA EQSIGN
-%token BINDSOCK SOCKCRED DOMAIN IPADDR IPNETWORK HOSTPORT NUMBER CHECK_TIMEOUT
+%token BINDSOCK SOCKCRED DOMAINNAME IPADDR IPNETWORK HOSTPORT NUMBER CHECK_TIMEOUT
%token MAXSIZE SIZELIMIT SECONDS BEANSTALK MYSQL USER PASSWORD DATABASE
%token TEMPDIR PIDFILE SERVERS ERROR_TIME DEAD_TIME MAXERRORS CONNECT_TIMEOUT PROTOCOL RECONNECT_TIMEOUT
%token READ_SERVERS WRITE_SERVER DIRECTORY_SERVERS MAILBOX_QUERY USERS_QUERY LASTLOGIN_QUERY
@@ -64,7 +51,7 @@ struct statfile *cur_statfile = NULL;
%type <string> SOCKCRED
%type <string> IPADDR IPNETWORK
%type <string> HOSTPORT
-%type <string> DOMAIN
+%type <string> DOMAINNAME
%type <limit> SIZELIMIT
%type <flag> FLAG
%type <seconds> SECONDS
@@ -169,7 +156,7 @@ bind_cred:
| IPADDR{
$$ = $1;
}
- | DOMAIN {
+ | DOMAINNAME {
$$ = $1;
}
| HOSTPORT {
@@ -247,7 +234,7 @@ memcached_params:
memcached_hosts:
STRING
| IPADDR
- | DOMAIN
+ | DOMAINNAME
| HOSTPORT
;
memcached_error_time:
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index 4df4bcaff..df8a2265f 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,32 +22,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <syslog.h>
-#include <netdb.h>
-#include <math.h>
#include "config.h"
#include "cfg_file.h"
#include "main.h"
#include "filter.h"
#include "classifiers/classifiers.h"
-#ifndef HAVE_OWN_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "queue.h"
-#endif
#define DEFAULT_SCORE 10.0
diff --git a/src/classifiers/classifiers.c b/src/classifiers/classifiers.c
index da6786795..283350972 100644
--- a/src/classifiers/classifiers.c
+++ b/src/classifiers/classifiers.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h
index 2a2929b7d..13a295724 100644
--- a/src/classifiers/classifiers.h
+++ b/src/classifiers/classifiers.h
@@ -1,12 +1,7 @@
#ifndef CLASSIFIERS_H
#define CLASSIFIERS_H
-#include <sys/types.h>
#include "../config.h"
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
#include "../mem_pool.h"
#include "../statfile.h"
#include "../tokenizers/tokenizers.h"
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index 494a5304a..1b3904e67 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -26,8 +26,6 @@
* Winnow classifier
*/
-#include <sys/types.h>
-#include <math.h>
#include "classifiers.h"
#define WINNOW_PROMOTION 1.23
diff --git a/src/controller.c b/src/controller.c
index 6b7a78ae9..41f8a9649 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,24 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <netinet/in.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <netdb.h>
-
-#include <glib.h>
-
+#include "config.h"
#include "util.h"
#include "main.h"
#include "message.h"
diff --git a/src/filter.c b/src/filter.c
index 562baac6c..088ac4376 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/filter.h b/src/filter.h
index b991109f9..c0b113dbd 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -6,13 +6,7 @@
#ifndef RSPAMD_FILTER_H
#define RSPAMD_FILTER_H
-#include <sys/types.h>
-#ifndef HAVE_OWN_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "queue.h"
-#endif
-#include <glib.h>
+#include "config.h"
struct worker_task;
diff --git a/src/fstring.c b/src/fstring.c
index 57f470ff7..75be14442 100644
--- a/src/fstring.c
+++ b/src/fstring.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,9 +22,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdlib.h>
-#include <string.h>
-
#include "fstring.h"
/*
diff --git a/src/hash.c b/src/hash.c
index 6b3851da3..20989474e 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,8 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <stdlib.h>
+#include "config.h"
#include "hash.h"
#define HASH_TABLE_MIN_SIZE 19
diff --git a/src/hash.h b/src/hash.h
index 4a1e973fb..024cb3851 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -7,8 +7,6 @@
#ifndef RSPAMD_HASH_H
#define RSPAMD_HASH_H
-#include <sys/types.h>
-#include <glib.h>
#include "mem_pool.h"
struct rspamd_hash_node {
diff --git a/src/main.c b/src/main.c
index 9def8513e..1a142c9f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,24 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#ifdef HAVE_LIBUTIL_H
-#include <libutil.h>
-#endif
-#include <syslog.h>
-
+#include "config.h"
#include "main.h"
#include "cfg_file.h"
#include "util.h"
@@ -324,7 +307,6 @@ main (int argc, char **argv, char **env)
PERL_SET_CONTEXT (perl_interpreter);
perl_construct (perl_interpreter);
- PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse (perl_interpreter, xs_init, 3, args, NULL);
/* Block signals to use sigsuspend in future */
sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL);
diff --git a/src/main.h b/src/main.h
index b037ee8cd..e1244d0ba 100644
--- a/src/main.h
+++ b/src/main.h
@@ -7,23 +7,6 @@
#define RSPAMD_MAIN_H
#include "config.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifndef HAVE_OWN_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "queue.h"
-#endif
-#include <sys/time.h>
-
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <signal.h>
-#include <event.h>
-
#include "fstring.h"
#include "mem_pool.h"
#include "statfile.h"
@@ -32,9 +15,6 @@
#include "protocol.h"
#include "filter.h"
-#include <glib.h>
-#include <gmime/gmime.h>
-
/* Default values */
#define FIXED_CONFIG_FILE "./rspamd.conf"
/* Time in seconds to exit for old worker */
diff --git a/src/mem_pool.c b/src/mem_pool.c
index 87895f87a..ecdfbb2b5 100644
--- a/src/mem_pool.c
+++ b/src/mem_pool.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,22 +22,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <errno.h>
#include "config.h"
-#ifdef HAVE_SCHED_YIELD
-#include <sched.h>
-#endif
-
-#ifdef HAVE_NANOSLEEP
-#include <time.h>
-#endif
-
#include "mem_pool.h"
/* Sleep time for spin lock in nanoseconds */
@@ -63,7 +49,7 @@ pthread_mutex_t stat_mtx = PTHREAD_MUTEX_INITIALIZER;
#undef MEMORY_GREEDY
/* Internal statistic */
-static memory_pool_stat_t *stat = NULL;
+static memory_pool_stat_t *mem_pool_stat = NULL;
static struct _pool_chain *
pool_chain_new (size_t size)
@@ -75,7 +61,7 @@ pool_chain_new (size_t size)
chain->pos = chain->begin;
chain->next = NULL;
STAT_LOCK ();
- stat->chunks_allocated ++;
+ mem_pool_stat->chunks_allocated ++;
STAT_UNLOCK ();
return chain;
@@ -112,7 +98,7 @@ pool_chain_new_shared (size_t size)
chain->lock = 0;
chain->next = NULL;
STAT_LOCK ();
- stat->shared_chunks_allocated ++;
+ mem_pool_stat->shared_chunks_allocated ++;
STAT_UNLOCK ();
return chain;
@@ -130,16 +116,16 @@ memory_pool_new (size_t size)
memory_pool_t *new;
/* Allocate statistic structure if it is not allocated before */
- if (stat == NULL) {
+ if (mem_pool_stat == NULL) {
#if defined(HAVE_MMAP_ANON)
- stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
+ mem_pool_stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
g_assert (stat != MAP_FAILED);
#elif defined(HAVE_MMAP_ZERO)
int fd;
fd = open ("/dev/zero", O_RDWR);
g_assert (fd != -1);
- stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ mem_pool_stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
g_assert (chain != MAP_FAILED);
#else
# error No mmap methods are defined
@@ -184,14 +170,14 @@ memory_pool_alloc (memory_pool_t *pool, size_t size)
pool->cur_pool = new;
new->pos += size;
STAT_LOCK ();
- stat->bytes_allocated += size;
+ mem_pool_stat->bytes_allocated += size;
STAT_UNLOCK ();
return new->begin;
}
tmp = cur->pos;
cur->pos += size;
STAT_LOCK ();
- stat->bytes_allocated += size;
+ mem_pool_stat->bytes_allocated += size;
STAT_UNLOCK ();
return tmp;
}
@@ -253,14 +239,14 @@ memory_pool_alloc_shared (memory_pool_t *pool, size_t size)
cur->next = new;
new->pos += size;
STAT_LOCK ();
- stat->bytes_allocated += size;
+ mem_pool_stat->bytes_allocated += size;
STAT_UNLOCK ();
return new->begin;
}
tmp = cur->pos;
cur->pos += size;
STAT_LOCK ();
- stat->bytes_allocated += size;
+ mem_pool_stat->bytes_allocated += size;
STAT_UNLOCK ();
return tmp;
}
@@ -370,7 +356,7 @@ memory_pool_delete (memory_pool_t *pool)
g_free (tmp->begin);
g_free (tmp);
STAT_LOCK ();
- stat->chunks_freed ++;
+ mem_pool_stat->chunks_freed ++;
STAT_UNLOCK ();
}
/* Unmap shared memory */
@@ -379,7 +365,7 @@ memory_pool_delete (memory_pool_t *pool)
cur_shared = cur_shared->next;
munmap (tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared));
STAT_LOCK ();
- stat->chunks_freed ++;
+ mem_pool_stat->chunks_freed ++;
STAT_UNLOCK ();
}
@@ -390,10 +376,10 @@ void
memory_pool_stat (memory_pool_stat_t *st)
{
if (stat) {
- st->bytes_allocated = stat->bytes_allocated;
- st->chunks_allocated = stat->chunks_allocated;
- st->shared_chunks_allocated = stat->shared_chunks_allocated;
- st->chunks_freed = stat->chunks_freed;
+ st->bytes_allocated = mem_pool_stat->bytes_allocated;
+ st->chunks_allocated = mem_pool_stat->chunks_allocated;
+ st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated;
+ st->chunks_freed = mem_pool_stat->chunks_freed;
}
}
diff --git a/src/mem_pool.h b/src/mem_pool.h
index 719aef220..af4f3d063 100644
--- a/src/mem_pool.h
+++ b/src/mem_pool.h
@@ -12,9 +12,7 @@
#ifndef RSPAMD_MEM_POOL_H
#define RSPAMD_MEM_POOL_H
-#include <sys/types.h>
-#include <glib.h>
-
+#include "config.h"
/**
* Destructor type definition
diff --git a/src/memcached-test.c b/src/memcached-test.c
index 319e55bec..ef81cf73c 100644
--- a/src/memcached-test.c
+++ b/src/memcached-test.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/memcached.c b/src/memcached.c
index 87536f8f1..d2636f5e6 100644
--- a/src/memcached.c
+++ b/src/memcached.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/message.c b/src/message.c
index f913c2648..5c0f15cf9 100644
--- a/src/message.c
+++ b/src/message.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,21 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#include <netdb.h>
-
-#include <glib.h>
-#include <gmime/gmime.h>
-
+#include "config.h"
#include "util.h"
#include "main.h"
#include "message.h"
diff --git a/src/message.h b/src/message.h
index 6fa4ad83c..1122e7e3b 100644
--- a/src/message.h
+++ b/src/message.h
@@ -8,27 +8,6 @@
#include "config.h"
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifndef HAVE_OWN_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "queue.h"
-#endif
-#include <sys/time.h>
-
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <signal.h>
-#include <event.h>
-
-#include "main.h"
-
-#include <glib.h>
-#include <gmime/gmime.h>
-
struct mime_part {
GMimeContentType *type;
GByteArray *content;
diff --git a/src/perl.c b/src/perl.c
index dc7864f20..eaa334d8d 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,15 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-
-#include <glib.h>
-
+#include "config.h"
#include "url.h"
#include "main.h"
#include "perl.h"
diff --git a/src/perl.h b/src/perl.h
index 7aabe1895..af97b6f46 100644
--- a/src/perl.h
+++ b/src/perl.h
@@ -1,8 +1,8 @@
#ifndef RSPAM_PERL_H
#define RSPAM_PERL_H
-#include <sys/types.h>
-#include <glib.h>
+
+#include "config.h"
#include "memcached.h"
#include <EXTERN.h> /* from the Perl distribution */
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 2e638dc47..1ecfcb36d 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -26,18 +26,6 @@
* rspamd module that implements different regexp rules
*/
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
#include <evdns.h>
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 37d6780a4..529fa5b09 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -26,19 +26,6 @@
* rspamd module that implements SURBL url checking
*/
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-
#include <evdns.h>
#include "../config.h"
diff --git a/src/protocol.c b/src/protocol.c
index c106b755f..92b331ac2 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,10 +22,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
#include "main.h"
#define CRLF "\r\n"
diff --git a/src/statfile.c b/src/statfile.c
index 80742311a..83d538256 100644
--- a/src/statfile.c
+++ b/src/statfile.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,17 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <time.h>
-#include <limits.h>
-#include <sys/mman.h>
#include "config.h"
-#include <string.h>
-#include <unistd.h>
-#include <glib.h>
#include "statfile.h"
#include "main.h"
diff --git a/src/statfile.h b/src/statfile.h
index 539fda842..88779ca16 100644
--- a/src/statfile.h
+++ b/src/statfile.h
@@ -7,12 +7,6 @@
#define RSPAMD_STATFILE_H
#include "config.h"
-#include <sys/types.h>
-#include <glib.h>
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
#include "mem_pool.h"
#include "hash.h"
diff --git a/src/tokenizers/osb.c b/src/tokenizers/osb.c
index 19646a1f3..a8469fc70 100644
--- a/src/tokenizers/osb.c
+++ b/src/tokenizers/osb.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/tokenizers/tokenizers.c b/src/tokenizers/tokenizers.c
index d2029a50f..48047d4fa 100644
--- a/src/tokenizers/tokenizers.c
+++ b/src/tokenizers/tokenizers.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/upstream.c b/src/upstream.c
index af99e1dfc..8bc636377 100644
--- a/src/upstream.c
+++ b/src/upstream.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
diff --git a/src/url.c b/src/url.c
index 10f639d59..09be6f112 100644
--- a/src/url.c
+++ b/src/url.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,17 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <syslog.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-
+#include "config.h"
#include "url.h"
#include "fstring.h"
#include "main.h"
diff --git a/src/url.h b/src/url.h
index 4964feadc..08a5cb0a6 100644
--- a/src/url.h
+++ b/src/url.h
@@ -2,17 +2,7 @@
#ifndef URL_H
#define URL_H
-#include <sys/types.h>
-#include <sys/socket.h>
#include "config.h"
-#if !defined(HAVE_OWN_QUEUE_H) && defined(HAVE_SYS_QUEUE_H)
-#include <sys/queue.h>
-#endif
-#ifdef HAVE_OWN_QUEUE_H
-#include "queue.h"
-#endif
-
-#include <glib.h>
#include "mem_pool.h"
struct worker_task;
diff --git a/src/util.c b/src/util.c
index 028bf5d4c..952c3a93e 100644
--- a/src/util.c
+++ b/src/util.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -22,25 +22,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/file.h>
-#include <syslog.h>
-#include <glib.h>
#include "config.h"
-#ifdef HAVE_LIBUTIL_H
-#include <libutil.h>
-#endif
#include "util.h"
#include "cfg_file.h"
diff --git a/src/util.h b/src/util.h
index 3036d37fd..fa5bbfbdb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,18 +1,7 @@
-#ifndef UTIL_H
-#define UTIL_H
-
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <signal.h>
+#ifndef RSPAMD_UTIL_H
+#define RSPAMD_UTIL_H
+#include "config.h"
#include "main.h"
struct config_file;
diff --git a/src/worker.c b/src/worker.c
index 7ef68dd95..caacda838 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -26,29 +26,7 @@
* Rspamd worker implementation
*/
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <netinet/in.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <netdb.h>
-
-#include <EXTERN.h> /* from the Perl distribution */
-#include <perl.h> /* from the Perl distribution */
-
-#include <glib.h>
-#include <event.h>
-#include <gmime/gmime.h>
-
+#include "config.h"
#include "util.h"
#include "main.h"
#include "protocol.h"
@@ -58,6 +36,9 @@
#include "modules.h"
#include "message.h"
+#include <EXTERN.h> /* from the Perl distribution */
+#include <perl.h> /* from the Perl distribution */
+
#define TASK_POOL_SIZE 4095
const f_str_t CRLF = {