As there are too many changes from 0.4.7 mark this version as 0.5.0.
PROJECT(rspamd C)
SET(RSPAMD_VERSION_MAJOR 0)
-SET(RSPAMD_VERSION_MINOR 4)
-SET(RSPAMD_VERSION_PATCH 8)
+SET(RSPAMD_VERSION_MINOR 5)
+SET(RSPAMD_VERSION_PATCH 0)
SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
ENDIF(OPENSSL_FOUND)
IF(ENABLE_STATIC MATCHES "ON")
- pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12)
+ pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12 gmodule-2.0)
+ SET(LINK_TYPE "STATIC")
ELSE(ENABLE_STATIC MATCHES "ON")
pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12 gmodule-2.0)
- SET(GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}")
+ SET(LINK_TYPE "SHARED")
ENDIF(ENABLE_STATIC MATCHES "ON")
+SET(GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}")
+
+IF(GLIB2_VERSION VERSION_GREATER "2.30.0")
+ pkg_check_modules(LIBFFI libffi)
+ IF(LIBFFI_FOUND)
+ SET(GLIB2_LDFLAGS "${GLIB2_LDFLAGS};${LIBFFI_LDFLAGS}")
+ SET(GLIB2_LIBRARIES "${GLIB2_LIBRARIES};${LIBFFI_LIBRARIES}")
+ SET(GLIB2_STATIC_LDFLAGS "${GLIB2_STATIC_LDFLAGS};${LIBFFI_STATIC_LDFLAGS}")
+ SET(GLIB2_CFLAGS "${GLIB2_CFLAGS};${LIBFFI_CFLAGS}")
+ ENDIF(LIBFFI_FOUND)
+ENDIF(GLIB2_VERSION VERSION_GREATER "2.30.0")
pkg_check_modules(GMIME2 gmime-2.0)
# Try to find hiredis library
################################ SUBDIRS SECTION ###########################
-ADD_SUBDIRECTORY(contrib/lgpl)
IF(GLIB_COMPAT)
+ ADD_SUBDIRECTORY(contrib/lgpl)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl")
ENDIF(GLIB_COMPAT)
IF(HAVE_LIBEVENT2)
TARGET_LINK_LIBRARIES(rspamd event_pthreads)
ENDIF(HAVE_LIBEVENT2)
-TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+IF(WITH_DB)
+ TARGET_LINK_LIBRARIES(rspamd db)
+ENDIF(WITH_DB)
+IF(SQLITE_LIBRARIES)
+ TARGET_LINK_LIBRARIES(rspamd ${SQLITE_LIBRARIES})
+ENDIF(SQLITE_LIBRARIES)
+IF(OPENSSL_FOUND)
+ TARGET_LINK_LIBRARIES(rspamd ${OPENSSL_LIBRARIES})
+ENDIF(OPENSSL_FOUND)
+TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+IF(GMIME24)
+ TARGET_LINK_LIBRARIES(rspamd ${GMIME24_LIBRARIES})
+ELSE(GMIME24)
+ TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES})
+ENDIF(GMIME24)
+TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd ${CMAKE_REQUIRED_LIBRARIES})
IF(ENABLE_STATIC MATCHES "ON")
TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+ TARGET_LINK_LIBRARIES(rspamd "z")
ENDIF(ENABLE_STATIC MATCHES "ON")
IF(ENABLE_LUAJIT MATCHES "ON")
# Add targets
# Rspamdutil
-ADD_LIBRARY(rspamd-util SHARED ${LIBRSPAMDUTILSRC})
+ADD_LIBRARY(rspamd-util ${LINK_TYPE} ${LIBRSPAMDUTILSRC})
IF(CMAKE_COMPILER_IS_GNUCC)
SET_TARGET_PROPERTIES(rspamd-util PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ARCHIVE DESTINATION ${LIBDIR})
# Rspamd client
-ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDCLIENTSRC})
+ADD_LIBRARY(rspamdclient ${LINK_TYPE} ${LIBRSPAMDCLIENTSRC})
ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDCLIENTSRC})
SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "client/librspamdclient.h")
LIST(APPEND LIBRSPAMDSERVERSRC ../src/kvstorage_sqlite.c)
ENDIF(WITH_SQLITE)
-ADD_LIBRARY(rspamd-server SHARED ${LIBRSPAMDSERVERSRC})
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
+ADD_LIBRARY(rspamd-server ${LINK_TYPE} ${LIBRSPAMDSERVERSRC})
+SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS "-DRSPAMD_LIB")
TARGET_LINK_LIBRARIES(rspamd-server rspamd-lua)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-json)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-util)
IF(CMAKE_COMPILER_IS_GNUCC)
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(WITH_DB)
ARCHIVE DESTINATION ${LIBDIR})
# Librspamdmime
-ADD_LIBRARY(rspamd-mime SHARED ${LIBRSPAMDMIMESRC})
+ADD_LIBRARY(rspamd-mime ${LINK_TYPE} ${LIBRSPAMDMIMESRC})
SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES LINKER_LANGUAGE C)
SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
TARGET_LINK_LIBRARIES(rspamd-mime rspamd-server)
TARGET_LINK_LIBRARIES(rspamd-mime rspamd-util)
IF(CMAKE_COMPILER_IS_GNUCC)
-SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(GMIME24)
# Libkvstorageclient
-ADD_LIBRARY(kvstorageclient SHARED ${LIBRKVSTORAGESRC})
+ADD_LIBRARY(kvstorageclient ${LINK_TYPE} ${LIBRKVSTORAGESRC})
ADD_LIBRARY(kvstorageclient_static STATIC ${LIBRKVSTORAGESRC})
SET_TARGET_PROPERTIES(kvstorageclient PROPERTIES PUBLIC_HEADER "kvstorage/libkvstorageclient.h")
cdb_find.c
cdb_make.c)
-ADD_LIBRARY(rspamd-cdb SHARED ${CDBSRC})
+ADD_LIBRARY(rspamd-cdb ${LINK_TYPE} ${CDBSRC})
SET_TARGET_PROPERTIES(rspamd-cdb PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
INSTALL(TARGETS rspamd-cdb
LIBRARY DESTINATION ${LIBDIR}
ADD_EXECUTABLE(rspamc ${RSPAMCSRC})
SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib")
-TARGET_LINK_LIBRARIES(rspamc rspamd-util)
-IF(ENABLE_STATIC MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamc rspamdclient_static)
-ELSE(ENABLE_STATIC MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamc rspamdclient)
-ENDIF(ENABLE_STATIC MATCHES "ON")
+TARGET_LINK_LIBRARIES(rspamc rspamd-server)
+TARGET_LINK_LIBRARIES(rspamc rspamdclient)
TARGET_LINK_LIBRARIES(rspamc pcre)
IF(GLIB_COMPAT)
TARGET_LINK_LIBRARIES(rspamc glibadditions)
utf.c
value.c)
-ADD_LIBRARY(rspamd-json SHARED ${JSONSRC})
+ADD_LIBRARY(rspamd-json ${LINK_TYPE} ${JSONSRC})
SET_TARGET_PROPERTIES(rspamd-json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
INSTALL(TARGETS rspamd-json
LIBRARY DESTINATION ${LIBDIR}
# define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, task->from_addr.s_addr, __FUNCTION__, __VA_ARGS__)
#endif
#else
-#define msg_err(...) rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_warn(...) rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_info(...) rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_debug(...) rspamd_fprintf(stderr, __VA_ARGS__)
-#define debug_task(...) rspamd_fprintf(stderr, __VA_ARGS__)
+#define msg_err(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_warn(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_info(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_debug(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define debug_task(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
#endif
#endif
lua_redis.c
lua_upstream.c)
-ADD_LIBRARY(rspamd-lua SHARED ${LUASRC})
+ADD_LIBRARY(rspamd-lua ${LINK_TYPE} ${LUASRC})
TARGET_LINK_LIBRARIES(rspamd-lua ${LUALIB})
SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
INSTALL(TARGETS rspamd-lua
return r;
}
+gint
+rspamd_log_fprintf (FILE *f, const gchar *fmt, ...)
+{
+ va_list args;
+ gchar buf[BUFSIZ];
+ gint r;
+
+ va_start (args, fmt);
+ rspamd_vsnprintf (buf, sizeof (buf), fmt, args);
+ va_end (args);
+
+ r = fprintf (f, "%s\n", buf);
+ fflush (f);
+
+ return r;
+}
+
gint
rspamd_sprintf (gchar *buf, const gchar *fmt, ...)
{
*/
gint rspamd_sprintf (gchar *buf, const gchar *fmt, ...);
gint rspamd_fprintf (FILE *f, const gchar *fmt, ...);
+gint rspamd_log_fprintf (FILE *f, const gchar *fmt, ...);
gint rspamd_snprintf (gchar *buf, glong max, const gchar *fmt, ...);
gchar *rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt, va_list args);