]> source.dussan.org Git - rspamd.git/commitdiff
Reorganize includes to reduce namespace pollution.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Oct 2015 12:15:15 +0000 (13:15 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Oct 2015 12:15:15 +0000 (13:15 +0100)
69 files changed:
config.h.in
contrib/aho-corasick/acism.c
contrib/cdb/cdb.h
src/CMakeLists.txt
src/client/rspamc.c
src/client/rspamdclient.c
src/client/rspamdclient.h
src/controller.c
src/http_proxy.c
src/libmime/filter.c
src/libmime/message.h
src/libmime/smtp_proto.c
src/libmime/smtp_utils.c
src/libserver/buffer.c
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c
src/libserver/dynamic_cfg.c
src/libserver/fuzzy_backend.c
src/libserver/proxy.c
src/libserver/proxy.h
src/libserver/roll_history.c
src/libserver/spf.h
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h
src/libserver/task.c
src/libserver/task.h
src/libserver/worker_util.c
src/libstat/backends/mmaped_file.c
src/libstat/backends/sqlite3_backend.c
src/libstat/classifiers/bayes.c
src/libutil/addr.c
src/libutil/addr.h
src/libutil/aio_event.c
src/libutil/http.c
src/libutil/logger.c
src/libutil/map.c
src/libutil/map.h
src/libutil/mem_pool.c
src/libutil/printf.c
src/libutil/rrd.c
src/libutil/sqlite_utils.c
src/libutil/str_util.c
src/libutil/unix-std.h [new file with mode: 0644]
src/libutil/util.c
src/libutil/util.h
src/lua/lua_buffer.c
src/lua/lua_cfg_file.c
src/lua/lua_http.c
src/lua/lua_rsa.c
src/lua/lua_tcp.c
src/lua/lua_util.c
src/lua_worker.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/plugins/spf.c
src/plugins/surbl.c
src/plugins/surbl.h
src/rspamadm/pw.c
src/rspamadm/rspamadm.c
src/rspamd.c
src/smtp_proxy.c
test/rspamd_async_test.c
test/rspamd_cryptobox_test.c
test/rspamd_http_test.c
test/rspamd_lua_test.c
test/rspamd_mem_pool_test.c
test/rspamd_shingles_test.c
test/rspamd_test_suite.c
test/rspamd_upstream_test.c

index da476a7587afe05d57af9b25974b40a4e6ad5b52..693a9380ebeae0e030fbeab94d89cbe273e1a036 100644 (file)
 #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/file.h */
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
-/* sys/uio.h */
-#ifdef HAVE_SYS_UIO_H
-#include <sys/uio.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>
 #include <time.h>
 #endif
 
-/* timedb */
-#ifdef HAVE_SYS_TIMEB_H
-#include <sys/timeb.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-/* sysexits */
-#ifdef HAVE_SYSEXITS_H
-#include <sysexits.h>
-#endif
-
-/* unistd */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
 #endif
 
-
 /* string */
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 
-/* strings */
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-/* fcntl */
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-/* Linux specific falloc.h */
-#ifdef HAVE_LINUX_FALLOC_H
-#include <linux/falloc.h>
-#endif
-
-/* poll */
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-
-/* sys/stat */
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-/* sys/wait */
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/* sys/resource.h */
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
-/* math */
-#ifdef HAVE_MATH_H
-#include <math.h>
-#endif
-
-/* libutil */
-#ifdef HAVE_LIBUTIL_H
-#include <libutil.h>
-#endif
-
-/* pwd and grp */
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-
-#ifdef HAVE_GLOB_H
-#include <glob.h>
-#endif
-
-/* syslog */
-#ifdef HAVE_SYSLOG_H
-#include <syslog.h>
-#endif
-
-#ifdef HAVE_LIBGEN_H
-#include <libgen.h>
-#define HAVE_DIRNAME 1
-#endif
-
-#ifdef HAVE_SEARCH_H
-#include <search.h>
-#endif
-
-#ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
-#endif
-
-#ifdef HAVE_SCHED_YIELD
-#include <sched.h>
-#endif
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
 #include <errno.h>
-#include <signal.h>
-#ifdef HAVE_SIGINFO_H
-# include <siginfo.h>
-#endif
-#include <event.h>
-#if _EVENT_NUMERIC_VERSION > 0x02000000
-# include <event2/thread.h>
-#endif
+
 #include <glib.h>
 
 
 typedef off_t goffset;
 #endif
 
-#ifndef BUILD_STATIC
-#include <gmodule.h>
-#endif
-
-#ifndef NO_GMIME
-#include <gmime/gmime.h>
-#endif
-
 #ifndef ALIGN
 #if defined(_MSC_VER)
 # define ALIGN(x) __declspec(align(x))
index 64e1eb956a1ec59f9ccb268fe5e8b6dfc3f6e28d..1117048051728b1f63a5a2727bbd67ac17d836b1 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "_acism.h"
+#include "unix-std.h"
 
 #define BACK ((SYMBOL)0)
 #define ROOT ((STATE) 0)
index 03da9ac41b794aed3f9a3a586e6141c112a1ce41..959c24f1fb2e2d84e188e5ff3503562006788fa2 100644 (file)
@@ -9,6 +9,8 @@
 #define TINYCDB_VERSION 0.77
 
 #include "config.h"
+#include "unix-std.h"
+#include <event.h>
 
 /*
  * OpenBSD fix
index 2561fa0ff641cddf1dccc0cc7aee3eaa4d645603..0490186dfbcd4e4e241f5c1f0120470be5da3669 100644 (file)
@@ -85,7 +85,7 @@ SET(PLUGINSSRC        plugins/surbl.c
                                plugins/chartable.c
                                plugins/fuzzy_check.c
                                plugins/spf.c
-                               plugins/dkim_check.c)
+                               plugins/dkim_check.c libutil/unix-std.h)
                                
 SET(MODULES_LIST surbl regexp chartable fuzzy_check spf dkim)
 SET(WORKERS_LIST normal controller smtp_proxy fuzzy lua http_proxy)
index 1d9252147c4e7a54f2215e1f536f9800fc900ec2..9be97cba0d632880787ad57798ff30d14b63ba03 100644 (file)
 #include "http.h"
 #include "rspamdclient.h"
 #include "utlist.h"
+#include "unix-std.h"
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 
 #define DEFAULT_PORT 11333
 #define DEFAULT_CONTROL_PORT 11334
@@ -1345,7 +1350,6 @@ main (gint argc, gchar **argv, gchar **env)
        event_base_loop (ev_base, 0);
 
        g_hash_table_destroy (kwattrs);
-       g_mime_shutdown ();
 
        /* Wait for children processes */
        cur = g_list_first (children);
index 272fe581bd607ae63f3e957016996ba70fd30a66..58ea0ad0ecb554b5a113b0ad918646ed37ba9ca9 100644 (file)
@@ -24,7 +24,7 @@
 #include "rspamdclient.h"
 #include "util.h"
 #include "http.h"
-#include "keypairs_cache.h"
+#include "unix-std.h"
 
 #ifdef HAVE_FETCH_H
 #include <fetch.h>
index 2a63b5a7fe2b3655d096c99a05ea9bd1923d7524..85b51514b6a2cb310fa8f81585e43c6666e8b816 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "config.h"
 #include "ucl.h"
+#include <event.h>
 
 struct rspamd_client_connection;
 struct rspamd_http_message;
index 871037b32e7cfb132ca41d8e00b8465262cc827d..6d14342d7b925238a43ab2c7f22d03afd3709344 100644 (file)
 #include "libstat/stat_api.h"
 #include "rspamd.h"
 #include "libserver/worker_util.h"
-#include "utlist.h"
-
-#include "blake2.h" 
 #include "cryptobox.h"
 #include "ottery.h"
 #include "libutil/rrd.h"
+#include "unix-std.h"
+#include <math.h>
 
 /* 60 seconds for worker's IO */
 #define DEFAULT_WORKER_IO_TIMEOUT 60000
index 6570e01cce36b618869e9c15b9be4d4c6b083f32..572d78578541e7383953de51f32f8950d4e57a67 100644 (file)
@@ -35,6 +35,7 @@
 #include "libserver/worker_util.h"
 #include "keypairs_cache.h"
 #include "ottery.h"
+#include "unix-std.h"
 
 /* Rotate keys each minute by default */
 #define DEFAULT_ROTATION_TIME 60.0
index ed50efafe9ef2f04b524323b75601ac27f40c40e..ab8833a8ae80104689d22bce3e4f4d2162561dcc 100644 (file)
 #include "filter.h"
 #include "rspamd.h"
 #include "message.h"
-#include "cfg_file.h"
-#include "util.h"
-#include "expression.h"
-#include "libstat/stat_api.h"
-#include "utlist.h"
-
-#ifdef WITH_LUA
-#   include "lua/lua_common.h"
-#endif
+#include "lua/lua_common.h"
+#include <math.h>
+
 
 #define COMMON_PART_FACTOR 95
 
index b509b23cd555950904c12f9563e5a716a024b36a..e980014481a4f6900e13ee404666bbb5f31f0082 100644 (file)
@@ -7,6 +7,7 @@
 #define RSPAMD_MESSAGE_H
 
 #include "config.h"
+#include <gmime/gmime.h>
 
 struct rspamd_task;
 struct controller_session;
index 05d5c43d51537c8adc68f019b4b664aa3d1d76c2..b6a14bdef69615f14fc70d277874d949eb1b280a 100644 (file)
@@ -29,6 +29,7 @@
 #include "smtp.h"
 #include "smtp_proto.h"
 #include "smtp_utils.h"
+#include "unix-std.h"
 
 gchar *
 make_smtp_error (rspamd_mempool_t *pool,
index df50abc6529ee1c3496bbc4ef3f4ef38de2a76d0..32b23bfd78a6d4878331d2b1c1d2b3585fe3573c 100644 (file)
@@ -23,9 +23,8 @@
 
 #include "config.h"
 #include "rspamd.h"
-#include "filter.h"
 #include "smtp.h"
-#include "smtp_proto.h"
+#include "unix-std.h"
 
 void
 free_smtp_session (gpointer arg)
index 0875de300396a7226f82d64002545c8dfcdbc439..4b8e3a3e5fb03f488fe54a08821ba8bcf7013f65 100644 (file)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "buffer.h"
 #include "rspamd.h"
+#include "unix-std.h"
 #ifdef HAVE_SYS_SENDFILE_H
 #include <sys/sendfile.h>
 #endif
index f50b37010a32d51ddb1938f5549eec1e7c593a00..57674aae399d9f4e43fe09df96d79315bc82a3a4 100644 (file)
 #include "expression.h"
 #include "composites.h"
 #include "libserver/worker_util.h"
+#include "unix-std.h"
+
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+
+#ifdef HAVE_GLOB_H
+#include <glob.h>
+#endif
 
 struct rspamd_rcl_default_handler_data {
        struct rspamd_rcl_struct_parser pd;
@@ -103,6 +112,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                }
                else if (g_ascii_strcasecmp (log_type, "syslog") == 0) {
                        /* Need to get facility */
+#ifdef HAVE_SYSLOG_H
                        cfg->log_facility = LOG_DAEMON;
                        cfg->log_type = RSPAMD_LOG_SYSLOG;
                        val = ucl_object_find_key (obj, "facility");
@@ -168,6 +178,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                                        return FALSE;
                                }
                        }
+#endif
                }
                else if (g_ascii_strcasecmp (log_type,
                        "stderr") == 0 || g_ascii_strcasecmp (log_type, "console") == 0) {
index 95c984b9c867adac63a8ee54a279e5a201708f9c..5e3bf1561c25397a6dc47e6ee90b92f32d9a0741 100644 (file)
@@ -34,6 +34,8 @@
 #include "dynamic_cfg.h"
 #include "utlist.h"
 #include "stat_api.h"
+#include "unix-std.h"
+#include <math.h>
 
 #define DEFAULT_SCORE 10.0
 
index eaa658b8bb0a237c79f6cade5123521ef92767ac..cbb7913a42910e6b75db9cc0c04a0311975ac42a 100644 (file)
@@ -26,6 +26,7 @@
 #include "map.h"
 #include "filter.h"
 #include "dynamic_cfg.h"
+#include "unix-std.h"
 
 struct config_json_buf {
        GString *buf;
index af6eb193d16da101334a37c60a8f861683cc0d31..41363ae13a1c4a29169ea8bc5223dbc10ea2f66a 100644 (file)
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "rspamd.h"
 #include "fuzzy_backend.h"
+#include "unix-std.h"
 
 #include <sqlite3.h>
 
index 09171eeb940a6ce6f8ea80ef51ddf06e5fca2a05..2eff2b08ec221e4a832a3bc1fa75128b13333b82 100644 (file)
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "rspamd.h"
 #include "proxy.h"
+#include "unix-std.h"
 
 static void rspamd_proxy_backend_handler (gint fd, gshort what, gpointer data);
 static void rspamd_proxy_client_handler (gint fd, gshort what, gpointer data);
index 784a78dbc942204d0b26b1562e7791bba1e7767c..a372f30e035f3ee14b436d77d9ccaa2a90b061e0 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "config.h"
 #include "buffer.h"
+#include <event.h>
 
 /**
  * @file proxy.h
index 74c7c8214f32e0ec311a74bb217ad0afc6d2693e..6c48fc224fb563c3d34f887ea8d756396c476fd2 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "rspamd.h"
 #include "roll_history.h"
+#include "unix-std.h"
 
 static const gchar rspamd_history_magic[] = {'r', 's', 'h', '1'};
 
index 473eff086b89e35fce2b1268ff1bf54500bf6fc8..cdb7a043408fac2d68a8c764a593e0ef10bb9b89 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "config.h"
 #include "ref.h"
+#include "addr.h"
 
 struct rspamd_task;
 struct spf_resolved;
index eaa4dce0399be0739fb95a5dbccce8cf368c6dbb..5e72eb97c37ff01e932dda46578e0709ae39404b 100644 (file)
@@ -29,6 +29,8 @@
 #include "symbols_cache.h"
 #include "cfg_file.h"
 #include "lua/lua_common.h"
+#include "unix-std.h"
+#include <math.h>
 
 #define msg_err_cache(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         cache->static_pool->tag.tagname, cache->cfg->checksum, \
index f6fffcc0896ba4f2c40f9df9d4a30774abfb2309..95f29224395907a23a7ffabd69aea503fd8befb3 100644 (file)
@@ -28,7 +28,7 @@
 #include "config.h"
 #include "ucl.h"
 #include <lua.h>
-#define MAX_SYMBOL 128
+#include <event.h>
 
 struct rspamd_task;
 struct rspamd_config;
index 6dd00b8bfec363c4024df636e283cf0dec0b8ffa..eaf845949a4089ec735eabc86374ba407faa49d1 100644 (file)
@@ -29,6 +29,7 @@
 #include "lua/lua_common.h"
 #include "composites.h"
 #include "stat_api.h"
+#include "unix-std.h"
 
 static GQuark
 rspamd_task_quark (void)
index 02f6f9ea0252b91290b1ec8ad19e99a4a45f7ebe..ee57c0f93d3d2f07f21e29bbfd70561ac5b3548a 100644 (file)
@@ -30,6 +30,8 @@
 #include "mem_pool.h"
 #include "dns.h"
 
+#include <gmime/gmime.h>
+
 enum rspamd_command {
        CMD_CHECK,
        CMD_SYMBOLS,
index ddd72acb94247db254453b6b234506a8922d2c48..71656116a5608304accbdcc6cfcda50728ee3c2c 100644 (file)
 #include "message.h"
 #include "lua/lua_common.h"
 #include "worker_util.h"
+#include "unix-std.h"
+#ifdef WITH_GPERF_TOOLS
+#include <google/profiler.h>
+#endif
 
 /**
  * Return worker's control structure by its type
index 41d6900cec90e0327ea3674f379e7c8800789d17..2daf6e6cb4ea42f8ab0780507e4768d872c73ed7 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "config.h"
 #include "stat_internal.h"
-#include "rspamd.h"
+#include "unix-std.h"
 
 #define CHAIN_LENGTH 128
 
index 26b9c56b4501f3fb264a2ba08a76b633ed7ebac2..a978f57531f8bacb569e40494fa205128b7f249a 100644 (file)
@@ -29,6 +29,7 @@
 #include "libstat/stat_internal.h"
 #include "libmime/message.h"
 #include "lua/lua_common.h"
+#include "unix-std.h"
 
 #define SQLITE3_BACKEND_TYPE "sqlite3"
 #define SQLITE3_SCHEMA_VERSION "1"
index 67c2e31162b6e32fea8995adacfff0e6326b0f5b..b0b2be4f3acb2e3f81a19189b9fcbd950ce8e218 100644 (file)
@@ -30,6 +30,7 @@
 #include "filter.h"
 #include "cfg_file.h"
 #include "stat_internal.h"
+#include "math.h"
 
 static inline GQuark
 bayes_error_quark (void)
index 4a48ab7e8cb4d0b84edb2e4753aeb4ebd13de652..1c7f4dbdfb4e935bc6da36a33ab053be9b002ede 100644 (file)
 #include "util.h"
 #include "logger.h"
 
+#include "unix-std.h"
+/* pwd and grp */
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+
 enum {
        RSPAMD_IPV6_UNDEFINED = 0,
        RSPAMD_IPV6_SUPPORTED,
index a13c14b53802562f314799b5f905a24a862ae488..affd871583052a578f6fa3413c03481329663c77 100644 (file)
 #define ADDR_H_
 
 #include "config.h"
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#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
+
 #include "mem_pool.h"
 
 /**
index 0686bbd0db23c4207a1d3f95c7efbe33f04a36b3..0c3a6f4fbc363b071d50e13917a640a120d462aa 100644 (file)
  */
 
 #include "config.h"
+#include <event.h>
 #include "aio_event.h"
 #include "rspamd.h"
+#include "unix-std.h"
 
 #ifdef HAVE_SYS_EVENTFD_H
 #include <sys/eventfd.h>
index fe7ac2d53405a9db5e4f4d422991b28c21005f2b..f363969b4f523175ea3b6156773e78d5a978f4c0 100644 (file)
@@ -32,7 +32,7 @@
 #include "ottery.h"
 #include "keypair_private.h"
 #include "cryptobox.h"
-#include <limits.h>
+#include "unix-std.h"
 
 #define ENCRYPTED_VERSION " HTTP/1.0"
 
index 3367829a6ef57bc4086a1b7f6e1d19fded0fcceb..b83aa5cd6555a899eff48315f3a72be8787683a1 100644 (file)
 #include "rspamd.h"
 #include "map.h"
 #include "xxhash.h"
+#include "unix-std.h"
+
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
 
 /* How much message should be repeated before it is count to be repeated one */
 #define REPEATS_MIN 3
@@ -174,9 +179,11 @@ rspamd_log_open_priv (rspamd_logger_t *rspamd_log, uid_t uid, gid_t gid)
                        rspamd_log->enabled = TRUE;
                        return 0;
                case RSPAMD_LOG_SYSLOG:
+#ifdef HAVE_SYSLOG_H
                        openlog ("rspamd", LOG_NDELAY | LOG_PID,
                                        rspamd_log->cfg->log_facility);
                        rspamd_log->enabled = TRUE;
+#endif
                        return 0;
                case RSPAMD_LOG_FILE:
                        rspamd_log->fd = open (rspamd_log->cfg->log_file,
@@ -212,7 +219,9 @@ rspamd_log_close_priv (rspamd_logger_t *rspamd_log, uid_t uid, gid_t gid)
                        /* Do nothing special */
                        break;
                case RSPAMD_LOG_SYSLOG:
+#ifdef HAVE_SYSLOG_H
                        closelog ();
+#endif
                        break;
                case RSPAMD_LOG_FILE:
                        if (rspamd_log->enabled) {
@@ -576,7 +585,7 @@ syslog_log_function (const gchar *log_domain,
                gpointer arg)
 {
        rspamd_logger_t *rspamd_log = arg;
-
+#ifdef HAVE_SYSLOG_H
        struct {
                GLogLevelFlags glib_level;
                gint syslog_level;
@@ -607,6 +616,7 @@ syslog_log_function (const gchar *log_domain,
                        module != NULL ? module : "",
                        function != NULL ? function : "",
                        message);
+#endif
 }
 
 /**
index 28faf13c40442e63ddd6a099a3f9bb6beb33b0f5..6c813a133c6b7300bc68623fd968fbd84a5bf2bf 100644 (file)
@@ -32,6 +32,7 @@
 #include "util.h"
 #include "mem_pool.h"
 #include "blake2.h"
+#include "unix-std.h"
 
 static const gchar *hash_fill = "1";
 
index 64421ec1b5305e5d2616bfb5bd91b4ac31149a1f..95c7de27b403896f5150decc770be3cba317b7c2 100644 (file)
@@ -2,6 +2,8 @@
 #define RSPAMD_MAP_H
 
 #include "config.h"
+#include <event.h>
+
 #include "mem_pool.h"
 #include "radix.h"
 
index 849e70c0312e47e31a1fa9d5fdb3f3990d1db747..e87a1578b846aaac35c55700b611b1bcf7caae1a 100644 (file)
 #include "logger.h"
 #include "utlist.h"
 #include "ottery.h"
+#include "unix-std.h"
+
+#ifdef HAVE_SCHED_YIELD
+#include <sched.h>
+#endif
 
 /* Sleep time for spin lock in nanoseconds */
 #define MUTEX_SLEEP_TIME 10000000L
index 3813524a04d3a2069b7791034a976977ee6815e3..67a2f3d98a1e6cbb215f60dfe3cdd422d6a635ac 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "printf.h"
 #include "fstring.h"
-#include "rspamd.h"
+#include <math.h>
 
 /**
  * From FreeBSD libutil code
@@ -449,7 +449,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
                                        if (*fmt == '*') {
                                                d = (gint)va_arg (args, gint);
                                                if (G_UNLIKELY (d < 0)) {
-                                                       msg_err ("critical error: fraction width is less than 0");
                                                        return 0;
                                                }
                                                frac_width = (guint)d;
@@ -466,7 +465,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
                                case '*':
                                        d = (gint)va_arg (args, gint);
                                        if (G_UNLIKELY (d < 0)) {
-                                               msg_err ("critical error: size is less than 0");
                                                return 0;
                                        }
                                        slen = (glong)d;
@@ -715,7 +713,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
                                continue;
 
                        case 'N':
-                               c = LF;
+                               c = '\n';
                                RSPAMD_PRINTF_APPEND (&c, 1);
 
                                continue;
index b7bd75d08b6c926817614f20d94ab22b00ef38a0..c5793a59038de38ce0a9edc1a74fdf4af4439d9c 100644 (file)
@@ -26,6 +26,8 @@
 #include "rrd.h"
 #include "util.h"
 #include "logger.h"
+#include "unix-std.h"
+#include <math.h>
 
 #define msg_err_rrd(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         "rrd", file->id, \
index 980d07abc5d7d6a7caeea706461a9b853cab7109..0458a0a020a2582bcdd718d5a66ca01da1abac28 100644 (file)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "libutil/logger.h"
 #include "libutil/sqlite_utils.h"
+#include "unix-std.h"
 
 
 static GQuark
index 96a26e1c1785c348e40686904506b1c204e92e04..9031305b02f1fe66f2a14bc83d5b4c35219addb5 100644 (file)
@@ -25,8 +25,8 @@
 
 #include "config.h"
 #include "util.h"
-#include "mem_pool.h"
 #include "xxhash.h"
+#include <math.h>
 
 static const guchar lc_map[256] = {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
diff --git a/src/libutil/unix-std.h b/src/libutil/unix-std.h
new file mode 100644 (file)
index 0000000..988669c
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015, Vsevolod Stakhov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *      * Redistributions of source code must retain the above copyright
+ *        notice, this list of conditions and the following disclaimer.
+ *      * Redistributions in binary form must reproduce the above copyright
+ *        notice, this list of conditions and the following disclaimer in the
+ *        documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR ''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 AUTHOR 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
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef RSPAMD_UNIX_STD_H_H
+#define RSPAMD_UNIX_STD_H_H
+
+#include "config.h"
+
+/*
+ * Default unix system includes
+ */
+
+/* sys/file.h */
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
+/* sys/uio.h */
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
+/* sys/mman */
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+
+/* timedb */
+#ifdef HAVE_SYS_TIMEB_H
+#include <sys/timeb.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* sysexits */
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#endif
+
+/* strings */
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+/* fcntl */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#include <signal.h>
+
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
+
+#endif
index daf427ef32e2b06ca6ad3849debffce6ff72346c..dae26a5c0c087552a26d7fcaaadda8870fa0c18f 100644 (file)
@@ -27,8 +27,7 @@
 #include "util.h"
 #include "cfg_file.h"
 #include "rspamd.h"
-#include "filter.h"
-#include "message.h"
+#include "unix-std.h"
 
 #include "xxhash.h"
 #include "ottery.h"
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
-
+/* libutil */
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
 #ifdef __APPLE__
 #include <mach/mach_time.h>
 #endif
+#ifdef WITH_GPERF_TOOLS
+#include <google/profiler.h>
+#endif
+/* poll */
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+
+#ifdef HAVE_SIGINFO_H
+#include <siginfo.h>
+#endif
+/* sys/wait */
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+/* sys/resource.h */
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
 
 #include "blake2.h"
 
index a78c4dfdac22b30e1eb3edf96d8c6e4b00298530..e563718f8bf7c32d8d3deca336eeea0b060e882c 100644 (file)
@@ -8,6 +8,11 @@
 #include "addr.h"
 #include "str_util.h"
 
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#include <event.h>
+
 struct rspamd_config;
 struct rspamd_main;
 struct workq;
index 021b13a0d4a632fc55f12b26eedd015911e8ebbf..d5f4c784840f06ecc9f7ebacf0810d23a840ef14 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "lua_common.h"
 #include "buffer.h"
+#include "unix-std.h"
+#include <math.h>
 
 /* Public prototypes */
 struct rspamd_io_dispatcher_s * lua_check_io_dispatcher (lua_State * L);
index bc9bdb3ac6afbac80d235c98f944aa8b148409f1..0a63164f59a790a58f44aa17ca26dbb1c1382c5d 100644 (file)
  */
 
 #include "lua_common.h"
-#include "symbols_cache.h"
 #include "expression.h"
-#include "filter.h"
 #include "composites.h"
+#include "unix-std.h"
 #ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
 #endif
index bbea1ebce6f88de2ac239ffe13982bf6223de281..6e0417a82586092125e859de68d919bb09cb5bb6 100644 (file)
@@ -26,6 +26,7 @@
 #include "dns.h"
 #include "http.h"
 #include "utlist.h"
+#include "unix-std.h"
 
 /***
  * @module rspamd_http
index a85d0db7150bc6d5eaffe1fb6570201a59a70373..b4b84d8964ac9a54aca89a0d451a9700b8e25140 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "lua_common.h"
+#include "unix-std.h"
 
 #ifdef HAVE_OPENSSL
 #include <openssl/err.h>
index 030f3109b745fdf8a6f25e5b06909c126f908785..afc1fd5d908af65010a4353271ba1304017888f7 100644 (file)
@@ -26,6 +26,7 @@
 #include "buffer.h"
 #include "dns.h"
 #include "utlist.h"
+#include "unix-std.h"
 
 static void lua_tcp_handler (int fd, short what, gpointer ud);
 /***
index 3a7d002118083c8ad5541b9193ddb98e99e82ff1..73099621f5615198719c38edb43231a9ae362a1c 100644 (file)
@@ -27,6 +27,7 @@
 #include "html.h"
 #include "cfg_rcl.h"
 #include "tokenizers/tokenizers.h"
+#include <math.h>
 
 /***
  * @module rspamd_util
index c378ffc0b63789d4c3efe3bf4de116e4254d6f31..b2a3ffc193945e761011983cdd48d2cdd8276adf 100644 (file)
@@ -33,6 +33,7 @@
 #include "message.h"
 #include "map.h"
 #include "dns.h"
+#include "unix-std.h"
 
 #include "lua/lua_common.h"
 
index 6ca18aaf88424af4aecedb0693cefb80903ad8b1..e7c932c99142aa51260130fb8e437e684ba6d5b5 100644 (file)
 #include "libserver/worker_util.h"
 #include "fuzzy_storage.h"
 #include "utlist.h"
-#include "rspamd.h"
 #include "blake2.h"
 #include "ottery.h"
-#include "cryptobox.h"
-#include "keypairs_cache.h"
 #include "keypair_private.h"
-#include "http.h"
+#include "unix-std.h"
+#include <math.h>
 
 #define DEFAULT_SYMBOL "R_FUZZY_HASH"
 #define DEFAULT_UPSTREAM_ERROR_TIME 10
index 2fd267aa0d510fd566d62e75090580bb6b1ab2f0..819bc762e36e393dcfe4c331750874c45bdc7fc0 100644 (file)
@@ -33,7 +33,6 @@
 #include "mime_expressions.h"
 #include "libutil/map.h"
 #include "lua/lua_common.h"
-#include "rspamd.h"
 
 struct regexp_module_item {
        struct rspamd_expression *expr;
index f19d2b50fbef084d084f103e9b6a1f8205122633..8780d8aa7c53e2838eba004ef0a559231006ee7d 100644 (file)
@@ -38,6 +38,7 @@
 #include "libutil/hash.h"
 #include "libutil/map.h"
 #include "rspamd.h"
+#include "addr.h"
 
 #define DEFAULT_SYMBOL_FAIL "R_SPF_FAIL"
 #define DEFAULT_SYMBOL_SOFTFAIL "R_SPF_SOFTFAIL"
index 7ce58ab1d64c86f018645fab975632d8430422f0..baf0706d84243d298f47e79403626931b76d7dc5 100644 (file)
 
 #include "config.h"
 #include "libmime/message.h"
-#include "libutil/hash.h"
 #include "libutil/map.h"
 #include "rspamd.h"
 #include "surbl.h"
-#include "regexp.h"
-#include "acism.h"
-
 #include "utlist.h"
+#include "unix-std.h"
 
 static struct surbl_ctx *surbl_module_ctx = NULL;
 
index 9eab930002966ef5119c98fb5f0620afc227308f..320423698dc0f1d8906a73c7cc3fcbc0656b092a 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "config.h"
 #include "acism.h"
-#include "rspamd.h"
 
 #define DEFAULT_REDIRECTOR_PORT 8080
 #define DEFAULT_SURBL_WEIGHT 10
index f72db4fa3732b2b7f4eb50429c715cb9afd56fd0..e090cd424485f20c4bc8ff5ab1526e3da8079311 100644 (file)
@@ -28,6 +28,7 @@
 #include "cryptobox.h"
 #include "rspamd.h"
 #include "rspamadm.h"
+#include "unix-std.h"
 
 static void rspamadm_pw (gint argc, gchar **argv);
 static const char *rspamadm_pw_help (gboolean full_help);
index 80c1801023a4a768d79111b509083cbe92db0d39..19dbea4a3e5e4fff482b2df6be255bc00fd58158 100644 (file)
 #include "rspamadm.h"
 #include "rspamd.h"
 #include "ottery.h"
+#include "unix-std.h"
+
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
 
 static gboolean verbose = FALSE;
 static gboolean list_commands = FALSE;
index 4faa2d36c6b216921f31fa6e8c99132c5833c8c7..743c34ced6c41085ea06be49b724ab4e3ae59f40 100644 (file)
 #include "rspamd.h"
 #include "libutil/map.h"
 #include "fuzzy_storage.h"
-#include "libserver/symbols_cache.h"
 #include "lua/lua_common.h"
 #include "libserver/worker_util.h"
 #include "ottery.h"
 #include "xxhash.h"
 #include "utlist.h"
-#include "libstat/stat_api.h"
-#include "cryptobox.h"
-#include "regexp.h"
+#include "unix-std.h"
+/* sysexits */
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#endif
+/* pwd and grp */
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#include <signal.h>
+#ifdef HAVE_SIGINFO_H
+#include <siginfo.h>
+#endif
+/* sys/resource.h */
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef WITH_GPERF_TOOLS
+#include <google/profiler.h>
+#endif
+
 #ifdef HAVE_OPENSSL
 #include <openssl/rand.h>
 #include <openssl/err.h>
index 43119afa2b74f5aeac46e8983deee32416089989..e93ef69ad4b388ef823e178f83415fd02691e928 100644 (file)
@@ -27,6 +27,7 @@
 #include "rspamd.h"
 #include "smtp.h"
 #include "libserver/worker_util.h"
+#include "unix-std.h"
 
 /*
  * SMTP proxy is a simple smtp proxy worker for dns resolving and
index 71eec712a078e5ad50ee78805fe6cec61d695966..fcd76333ffa7c49897dc3f733cd70f814ad5bbfa 100644 (file)
  */
 
 #include "config.h"
-#include "tests.h"
 #include "rspamd.h"
 #include "aio_event.h"
-#include "mem_pool.h"
-
+#include "unix-std.h"
 
 extern struct event_base *base;
 
index c7ad2921cea59637ddb976561ccd1f7145b9d806..d01d99ee3ab82711e0f0ff3866612a879d1f73f8 100644 (file)
@@ -29,6 +29,7 @@
 #include "fstring.h"
 #include "ottery.h"
 #include "cryptobox.h"
+#include "unix-std.h"
 
 static const int mapping_size = 64 * 8192 + 1;
 static const int max_seg = 32;
index 429ae5be98ed452d1a5d5beeb9d345527b5ffadf..81b598a45213c1b6028f6a85b346a3bdaf9c49cf 100644 (file)
 #include "tests.h"
 #include "ottery.h"
 #include "cryptobox.h"
+#include "unix-std.h"
+#include <math.h>
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 
 static const int file_blocks = 1;
 static const int pconns = 100;
index caeb9814ef8bb862ba632bf49b5f5fc93fcde3d7..8b1b0938342fbe6ad1664a514d65127fa7198e0e 100644 (file)
 #include "rspamd.h"
 #include "util.h"
 #include "lua/lua_common.h"
+#include "unix-std.h"
+
+#ifdef HAVE_GLOB_H
+#include <glob.h>
+#endif
 
 static const char *lua_src = BUILDROOT "/test/lua/tests.lua";
 
index fe5ba56b827aebd5f95b45d0b8639ee6a6362d87..e8813f574d36f5260d9b5119e5ada9f8791707a6 100644 (file)
@@ -1,6 +1,12 @@
 #include "config.h"
 #include "mem_pool.h"
 #include "tests.h"
+#include "unix-std.h"
+#include <math.h>
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 
 #define TEST_BUF "test bufffer"
 #define TEST2_BUF "test bufffertest bufffer"
index 3a1dd8ba2ad897503dfd7c17aeb092f481155895..2b33ad684ee0dbb22c4f8626d532c537b2327c98 100644 (file)
@@ -24,8 +24,8 @@
 #include "config.h"
 #include "rspamd.h"
 #include "shingles.h"
-#include "fstring.h"
 #include "ottery.h"
+#include <math.h>
 
 static void
 generate_random_string (char *begin, size_t len)
index e10ebd88925831fc9cf79f1733317ef0207af018..97d0565b80e7348aebb87f264a849b1c805f30bb 100644 (file)
@@ -1,7 +1,5 @@
 #include "config.h"
 #include "rspamd.h"
-#include "cfg_file.h"
-#include "regexp.h"
 #include "libstat/stat_api.h"
 #include "tests.h"
 
index 9e04c4ddaab2e5400dfcda2d0555e168524e91f4..e2f2c17eef17f8f33473ba0e672e73b3e9ce320c 100644 (file)
@@ -25,8 +25,8 @@
 
 #include "config.h"
 #include "rspamd.h"
-#include "upstream.h"
 #include "ottery.h"
+#include <math.h>
 
 const char *test_upstream_list = "microsoft.com:443:1,google.com:80:2,kernel.org:443:3";
 const char *new_upstream_list = "freebsd.org:80";