diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-23 14:45:33 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-23 14:45:33 +0400 |
commit | 18ce6f0c60f1125c5344d9fd8e90e5ea2941bf01 (patch) | |
tree | eb79d0b925375a19aae1f7e88323621990c72150 | |
parent | 80e9384ebfaca000eb7f0693a466795f51e3f29d (diff) | |
download | rspamd-18ce6f0c60f1125c5344d9fd8e90e5ea2941bf01.tar.gz rspamd-18ce6f0c60f1125c5344d9fd8e90e5ea2941bf01.zip |
* Fix compatibility issues
-rw-r--r-- | CMakeLists.txt | 17 | ||||
-rw-r--r-- | compat/queue.h | 2 | ||||
-rw-r--r-- | config.h.in | 7 | ||||
-rw-r--r-- | src/cfg_file.h | 8 | ||||
-rw-r--r-- | src/html.c | 27 | ||||
-rw-r--r-- | src/logger.h | 14 | ||||
-rw-r--r-- | src/main.h | 12 | ||||
-rw-r--r-- | src/mem_pool.c | 10 | ||||
-rw-r--r-- | src/plugins/regexp.c | 2 | ||||
-rw-r--r-- | src/util.c | 11 | ||||
-rw-r--r-- | src/util.h | 2 | ||||
-rw-r--r-- | src/worker.c | 2 |
12 files changed, 80 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ab2e11ce0..1605bd41b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,18 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") +IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS") + IF(NOT ETC_PREFIX) + SET(ETC_PREFIX /etc) + SET(PREFIX /opt/rspamd) + ENDIF(NOT ETC_PREFIX) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES m) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + IF(ENABLE_PERL MATCHES "ON") IF(NOT PERL_EXECUTABLE) @@ -570,6 +582,7 @@ ENDIF(LIBJUDY_LIBRARY) TARGET_LINK_LIBRARIES(rspamd rspamd_evdns) TARGET_LINK_LIBRARIES(rspamd event) TARGET_LINK_LIBRARIES(rspamd rspamd_json) +TARGET_LINK_LIBRARIES(rspamd ${CMAKE_REQUIRED_LIBRARIES}) TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES}) IF(GMIME2_FOUND) TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES}) @@ -588,6 +601,7 @@ ADD_EXECUTABLE(test/rspamd-test ${TESTDEPENDS} ${CONTRIBSRC} ${TESTSRC}) SET_TARGET_PROPERTIES(test/rspamd-test PROPERTIES LINKER_LANGUAGE C) TARGET_LINK_LIBRARIES(test/rspamd-test event) TARGET_LINK_LIBRARIES(test/rspamd-test ${GLIB2_LIBRARIES}) +TARGET_LINK_LIBRARIES(test/rspamd-test ${CMAKE_REQUIRED_LIBRARIES}) IF(GMIME2_FOUND) TARGET_LINK_LIBRARIES(test/rspamd-test ${GMIME2_LIBRARIES}) ELSE(GMIME2_FOUND) @@ -599,6 +613,7 @@ ENDIF(ENABLE_STATIC MATCHES "ON") ADD_EXECUTABLE(utils/url-extracter ${UTILSDEPENDS} ${CONTRIBSRC} ${UTILSSRC}) SET_TARGET_PROPERTIES(utils/url-extracter PROPERTIES LINKER_LANGUAGE C) +TARGET_LINK_LIBRARIES(utils/url-extracter ${CMAKE_REQUIRED_LIBRARIES}) TARGET_LINK_LIBRARIES(utils/url-extracter ${GLIB2_LIBRARIES}) IF(GMIME2_FOUND) TARGET_LINK_LIBRARIES(utils/url-extracter ${GMIME2_LIBRARIES}) @@ -611,7 +626,7 @@ ENDIF(ENABLE_STATIC MATCHES "ON") ADD_EXECUTABLE(utils/expression-parser ${UTILSDEPENDS} ${CONTRIBSRC} ${EXPRSRC}) SET_TARGET_PROPERTIES(utils/expression-parser PROPERTIES LINKER_LANGUAGE C) -TARGET_LINK_LIBRARIES(utils/expression-parser m) +TARGET_LINK_LIBRARIES(utils/expression-parser ${CMAKE_REQUIRED_LIBRARIES}) IF(LIBUTIL_LIBRARY) TARGET_LINK_LIBRARIES(utils/expression-parser util) ENDIF(LIBUTIL_LIBRARY) diff --git a/compat/queue.h b/compat/queue.h index d62afcc84..71190fe40 100644 --- a/compat/queue.h +++ b/compat/queue.h @@ -33,8 +33,6 @@ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ -#include <sys/cdefs.h> - /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. diff --git a/config.h.in b/config.h.in index 7ceb0aaec..15b629507 100644 --- a/config.h.in +++ b/config.h.in @@ -240,10 +240,15 @@ /* string */ -#ifdef HAVE_STDIO_H +#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> diff --git a/src/cfg_file.h b/src/cfg_file.h index e788be2e6..24b8b327e 100644 --- a/src/cfg_file.h +++ b/src/cfg_file.h @@ -49,7 +49,7 @@ enum rspamd_cred_type { CRED_NORMAL, CRED_CONTROL, CRED_LMTP, - CRED_DELIVERY, + CRED_DELIVERY }; /** @@ -61,7 +61,7 @@ enum rspamd_regexp_type { REGEXP_MIME, REGEXP_MESSAGE, REGEXP_URL, - REGEXP_RAW_HEADER, + REGEXP_RAW_HEADER }; /** @@ -70,7 +70,7 @@ enum rspamd_regexp_type { enum rspamd_log_type { RSPAMD_LOG_CONSOLE, RSPAMD_LOG_SYSLOG, - RSPAMD_LOG_FILE, + RSPAMD_LOG_FILE }; /** @@ -201,7 +201,7 @@ struct config_scalar { SCALAR_TYPE_INT, SCALAR_TYPE_UINT, SCALAR_TYPE_STR, - SCALAR_TYPE_SIZE, + SCALAR_TYPE_SIZE } type; /**< type of data */ }; diff --git a/src/html.c b/src/html.c index 654366799..243759fa7 100644 --- a/src/html.c +++ b/src/html.c @@ -639,6 +639,29 @@ decode_entitles (char *s, guint * len) } } +/* + * Find the first occurrence of find in s, ignore case. + */ +static gchar * +html_strcasestr (const gchar *s, const gchar *find) +{ + char c, sc; + size_t len; + + if ((c = *find++) != 0) { + c = g_ascii_tolower (c); + len = strlen (find); + do { + do { + if ((sc = *s++) == 0) + return (NULL); + } while (g_ascii_tolower (sc) != c); + } while (g_ascii_strncasecmp (s, find, len) != 0); + s--; + } + return ((gchar *)s); +} + static void parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id, char *tag_text) { @@ -650,11 +673,11 @@ parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t i /* For A tags search for href= and for IMG tags search for src= */ if (id == Tag_A) { - c = strcasestr (tag_text, "href="); + c = html_strcasestr (tag_text, "href="); len = sizeof ("href=") - 1; } else if (id == Tag_IMG) { - c = strcasestr (tag_text, "src="); + c = html_strcasestr (tag_text, "src="); len = sizeof ("src=") - 1; } diff --git a/src/logger.h b/src/logger.h index c923b25ed..8e517541e 100644 --- a/src/logger.h +++ b/src/logger.h @@ -5,8 +5,18 @@ #include "cfg_file.h" #include "radix.h" -/* Forwarded declaration */ -enum process_type; +/** + * Process type: main or worker + */ +enum process_type { + TYPE_MAIN, + TYPE_WORKER, + TYPE_CONTROLLER, + TYPE_LMTP, + TYPE_SMTP, + TYPE_FUZZY, + TYPE_GREYLIST +}; typedef void (*rspamd_log_func_t)(const gchar * log_domain, const gchar *function, GLogLevelFlags log_level, const gchar * message, diff --git a/src/main.h b/src/main.h index 4b407d705..233fd6159 100644 --- a/src/main.h +++ b/src/main.h @@ -39,18 +39,6 @@ #define CR '\r' #define LF '\n' -/** - * Process type: main or worker - */ -enum process_type { - TYPE_MAIN, - TYPE_WORKER, - TYPE_CONTROLLER, - TYPE_LMTP, - TYPE_SMTP, - TYPE_FUZZY, - TYPE_GREYLIST -}; /** diff --git a/src/mem_pool.c b/src/mem_pool.c index 363116ce5..8d5c22ad1 100644 --- a/src/mem_pool.c +++ b/src/mem_pool.c @@ -83,7 +83,7 @@ pool_chain_new_shared (memory_pool_ssize_t size) struct _pool_chain_shared *chain; #if defined(HAVE_MMAP_ANON) - chain = mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); + chain = (struct _pool_chain_shared *)mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); g_assert (chain != MAP_FAILED); chain->begin = ((u_char *) chain) + sizeof (struct _pool_chain_shared); g_assert (chain->begin != MAP_FAILED); @@ -94,7 +94,7 @@ pool_chain_new_shared (memory_pool_ssize_t size) if (fd == -1) { return NULL; } - chain = mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + chain = (struct _pool_chain_shared *)mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); g_assert (chain != MAP_FAILED); chain->begin = ((u_char *) chain) + sizeof (struct _pool_chain_shared); g_assert (chain->begin != MAP_FAILED); @@ -127,14 +127,14 @@ memory_pool_new (memory_pool_ssize_t size) /* Allocate statistic structure if it is not allocated before */ if (mem_pool_stat == NULL) { #if defined(HAVE_MMAP_ANON) - mem_pool_stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); + mem_pool_stat = (memory_pool_stat_t *)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); - mem_pool_stat = mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + mem_pool_stat = (memory_pool_stat_t *)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 @@ -474,7 +474,7 @@ memory_pool_delete (memory_pool_t * pool) while (cur_shared) { tmp_shared = cur_shared; cur_shared = cur_shared->next; - munmap (tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared)); + munmap ((void *)tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared)); STAT_LOCK (); mem_pool_stat->chunks_freed++; STAT_UNLOCK (); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 2b52f4d8f..7a0d1b0b8 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -27,7 +27,6 @@ */ -#include <evdns.h> #include "../config.h" #include "../main.h" @@ -40,6 +39,7 @@ #include "../view.h" #include "../lua/lua_common.h" #include "../json/jansson.h" +#include "../evdns/evdns.h" #define DEFAULT_STATFILE_PREFIX "./" diff --git a/src/util.c b/src/util.c index 7e9aeb463..67b93337e 100644 --- a/src/util.c +++ b/src/util.c @@ -112,6 +112,8 @@ make_inet_socket (int family, struct in_addr *addr, u_short port, gboolean is_se goto out; } + memset (&sin, 0, sizeof (sin)); + /* Bind options */ sin.sin_family = AF_INET; sin.sin_port = htons (port); @@ -418,6 +420,10 @@ setproctitle (const char *fmt, ...) int init_title (int argc, char *argv[], char *envp[]) { +#if defined(DARWIN) || defined(SOLARIS) + /* XXX: try to handle these OSes too */ + return 0; +#else char *begin_of_buffer = 0, *end_of_buffer = 0; int i; @@ -478,6 +484,7 @@ init_title (int argc, char *argv[], char *envp[]) } g_free (new_environ); return 0; +#endif } #endif @@ -541,7 +548,7 @@ pidfile_open (const char *path, mode_t mode, pid_t * pidptr) return NULL; if (path == NULL) - len = snprintf (pfh->pf_path, sizeof (pfh->pf_path), "/var/run/%s.pid", __progname); + len = snprintf (pfh->pf_path, sizeof (pfh->pf_path), "/var/run/%s.pid", g_get_prgname ()); else len = snprintf (pfh->pf_path, sizeof (pfh->pf_path), "%s", path); if (len >= (int)sizeof (pfh->pf_path)) { @@ -626,7 +633,7 @@ pidfile_write (struct pidfh *pfh) return -1; } - snprintf (pidstr, sizeof (pidstr), "%u", getpid ()); + snprintf (pidstr, sizeof (pidstr), "%lu", (long unsigned)getpid ()); if (pwrite (fd, pidstr, strlen (pidstr), 0) != (ssize_t) strlen (pidstr)) { error = errno; _pidfile_remove (pfh, 0); diff --git a/src/util.h b/src/util.h index 1e7df2378..89a430d52 100644 --- a/src/util.h +++ b/src/util.h @@ -53,7 +53,7 @@ struct pidfh { #else char pf_path[1024 + 1]; #endif - __dev_t pf_dev; + dev_t pf_dev; ino_t pf_ino; }; struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr); diff --git a/src/worker.c b/src/worker.c index bfc4e4331..5e803cc78 100644 --- a/src/worker.c +++ b/src/worker.c @@ -37,7 +37,7 @@ #include "message.h" #include "map.h" -#include <evdns.h> +#include "evdns/evdns.h" #ifndef WITHOUT_PERL # include <EXTERN.h> /* from the Perl distribution */ |