]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
* Fix compatibility issues
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 23 Jun 2010 10:45:33 +0000 (14:45 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 23 Jun 2010 10:45:33 +0000 (14:45 +0400)
12 files changed:
CMakeLists.txt
compat/queue.h
config.h.in
src/cfg_file.h
src/html.c
src/logger.h
src/main.h
src/mem_pool.c
src/plugins/regexp.c
src/util.c
src/util.h
src/worker.c

index ab2e11ce0c37ee6999ed3009b466e844ac892196..1605bd41bb61fe4a3bb0021ed97d8837d4632515 100644 (file)
@@ -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)
index d62afcc8472f2bbd1c2f6025c790744cc227bcb3..71190fe40f2f386da4106802f615dfc9163d6c6e 100644 (file)
@@ -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.
index 7ceb0aaec3522cbd562ec992ff676b6b5776315b..15b6295072d8af77a8dbeaf5b324f5ce6a205649 100644 (file)
 
 
 /* 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>
index e788be2e6df6a1ebac57e0a1d2e86139b432df0a..24b8b327eccd3419a6b82ae0734795a7b454ea17 100644 (file)
@@ -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                                                                               */
 };
 
index 6543667993f9be539c163b3f19299e9e0314ffe7..243759fa707892d22532fb5c083303c199fc61e5 100644 (file)
@@ -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;
        }
 
index c923b25ed015e715eaf6cf6d85a7ed07aa35a08f..8e517541e83c79137f63579e1d288462ca6edaa2 100644 (file)
@@ -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, 
index 4b407d70518e93497ae13bd1c1d07beae0d07d71..233fd6159b8d3c9c0c48ce04ea4b8c4e29187756 100644 (file)
 #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
-};
 
 
 /** 
index 363116ce5c76644beec531704c15cdf71d4d7267..8d5c22ad109f61e44af3aafa10aa53c03e6f287c 100644 (file)
@@ -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 ();
index 2b52f4d8fa94836ee42950690c4216b52238f316..7a0d1b0b866951ec26ac9b6a6db08fa14997eab9 100644 (file)
@@ -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 "./"
 
index 7e9aeb463a9661fc1baa1084f050643cd9632b04..67b93337e7029b54efa409c22e70804c602ddb39 100644 (file)
@@ -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);
index 1e7df23784095d7a399492a7ef2e95fd53b98403..89a430d52993dbcd2821e09eeb5e7f8caa2fb112 100644 (file)
@@ -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);
index bfc4e4331d5385ca03cddbde85a9fb35a89015c9..5e803cc785ca602113b7614f614c24ee304971e5 100644 (file)
@@ -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     */