1#ifndef RSPAMD_CONFIG_H_IN 2#define RSPAMD_CONFIG_H_IN 3 4 5#cmakedefine BUILD_STATIC 1 6#cmakedefine CURL_FOUND 1 7#cmakedefine DEBUG_MODE 1 8#cmakedefine GIT_VERSION 1 9#cmakedefine GLIB_COMPAT 1 10#cmakedefine GLIB_HASH_COMPAT 1 11#cmakedefine GLIB_RE_COMPAT 1 12#cmakedefine GLIB_UNISCRIPT_COMPAT 1 13#cmakedefine HAVE_ARPA_INET_H 1 14#cmakedefine HAVE_ATOMIC_BUILTINS 1 15#cmakedefine HAVE_CLOCK_GETCPUCLOCKID 1 16#cmakedefine HAVE_CLOCK_GETTIME 1 17#cmakedefine HAVE_CLOCK_PROCESS_CPUTIME_ID 1 18#cmakedefine HAVE_CLOCK_VIRTUAL 1 19#cmakedefine HAVE_CPUID_H 1 20#cmakedefine HAVE_CTYPE_H 1 21#cmakedefine HAVE_DIRENT_H 1 22#cmakedefine HAVE_DIRFD 1 23#cmakedefine HAVE_ENDIAN_H 1 24#cmakedefine HAVE_FALLOCATE 1 25#cmakedefine HAVE_FCNTL_H 1 26#cmakedefine HAVE_FETCH_H 1 27#cmakedefine HAVE_FIPS_MODE 1 28#cmakedefine HAVE_FLOCK 1 29#cmakedefine HAVE_FPATHCONF 1 30#cmakedefine HAVE_GETPAGESIZE 1 31#cmakedefine HAVE_GLOB_H 1 32#cmakedefine HAVE_GRP_H 1 33#cmakedefine HAVE_INTTYPES_H 1 34#cmakedefine HAVE_IPV6_V6ONLY 1 35#cmakedefine HAVE_LIBGEN_H 1 36#cmakedefine HAVE_LIBUTIL_H 1 37#cmakedefine HAVE_LOCALE_H 1 38#cmakedefine HAVE_MACHINE_ENDIAN_H 1 39#cmakedefine HAVE_MAXPATHLEN 1 40#cmakedefine HAVE_FMEMOPEN 1 41#cmakedefine HAVE_MEMRCHR 1 42#cmakedefine HAVE_MKSTEMP 1 43#cmakedefine HAVE_MMAP_ANON 1 44#cmakedefine HAVE_NANOSLEEP 1 45#cmakedefine HAVE_NETDB_H 1 46#cmakedefine HAVE_NETINET_IN_H 1 47#cmakedefine HAVE_NETINET_TCP_H 1 48#cmakedefine HAVE_NFTW 1 49#cmakedefine HAVE_OCLOEXEC 1 50#cmakedefine HAVE_ONOFOLLOW 1 51#cmakedefine HAVE_OPENMEMSTREAM 1 52#cmakedefine HAVE_PATH_MAX 1 53 54/* OSX has broken JIT support in PCRE, disable it */ 55#ifndef __APPLE__ 56#cmakedefine HAVE_PCRE_JIT 1 57#cmakedefine HAVE_PCRE_JIT_FAST 1 58#endif 59 60#cmakedefine HAVE_PIDFILE 1 61#cmakedefine HAVE_PIDFILE_FILENO 1 62#cmakedefine HAVE_POLL_H 1 63#cmakedefine HAVE_POSIX_FALLOCATE 1 64#cmakedefine HAVE_PTHREAD_PROCESS_SHARED 1 65#cmakedefine HAVE_PWD_H 1 66#cmakedefine HAVE_RDTSC 1 67#cmakedefine HAVE_READAHEAD 1 68#cmakedefine HAVE_READPASSPHRASE_H 1 69#cmakedefine HAVE_RECVMMSG 1 70#cmakedefine HAVE_RUSAGE_SELF 1 71#cmakedefine HAVE_SA_SIGINFO 1 72#cmakedefine HAVE_SANE_SHMEM 1 73#cmakedefine HAVE_SCHED_YIELD 1 74#cmakedefine HAVE_SC_NPROCESSORS_ONLN 1 75#cmakedefine HAVE_SETPROCTITLE 1 76#cmakedefine HAVE_SIGALTSTACK 1 77#cmakedefine HAVE_SIGINFO_H 1 78#cmakedefine HAVE_SOCK_SEQPACKET 1 79#cmakedefine HAVE_SSL_TLSEXT_HOSTNAME 1 80#cmakedefine HAVE_STDBOOL_H 1 81#cmakedefine HAVE_STDINT_H 1 82#cmakedefine HAVE_STDIO_H 1 83#cmakedefine HAVE_STDLIB_H 1 84#cmakedefine HAVE_STRINGS_H 1 85#cmakedefine HAVE_STRING_H 1 86#cmakedefine HAVE_SYSLOG_H 1 87#cmakedefine HAVE_SYS_CDEFS_H 1 88#cmakedefine HAVE_SYS_ENDIAN_H 1 89#cmakedefine HAVE_SYS_EVENTFD_H 1 90#cmakedefine HAVE_SYS_FILE_H 1 91#cmakedefine HAVE_SYS_MMAN_H 1 92#cmakedefine HAVE_SYS_PARAM_H 1 93#cmakedefine HAVE_SYS_RESOURCE_H 1 94#cmakedefine HAVE_SYS_SOCKET_H 1 95#cmakedefine HAVE_SYS_STAT_H 1 96#cmakedefine HAVE_SYS_TIMEB_H 1 97#cmakedefine HAVE_SYS_TYPES_H 1 98#cmakedefine HAVE_SYS_UCONTEXT_H 1 99#cmakedefine HAVE_SYS_UIO_H 1 100#cmakedefine HAVE_SYS_UN_H 1 101#cmakedefine HAVE_SYS_WAIT_H 1 102#cmakedefine HAVE_TANH 1 103#cmakedefine HAVE_TERMIOS_H 1 104#cmakedefine HAVE_TIME_H 1 105#cmakedefine HAVE_UCONTEXT_H 1 106#cmakedefine HAVE_UNISTD_H 1 107#cmakedefine PARAM_H_HAS_BITSET 1 108#cmakedefine WITH_GPERF_TOOLS 1 109#cmakedefine WITH_HYPERSCAN 1 110#cmakedefine WITH_JEMALLOC 1 111#cmakedefine WITH_LUA 1 112#cmakedefine WITH_LUAJIT 1 113#cmakedefine WITH_PCRE2 1 114#cmakedefine WITH_SNOWBALL 1 115#cmakedefine WITH_SQLITE 1 116#cmakedefine WITH_LIBUNWIND 1 117#cmakedefine WITH_LUA_TRACE 1 118#cmakedefine WITH_LUA_REPL 1 119 120#cmakedefine DISABLE_PTHREAD_MUTEX 1 121 122/* Detect endianness */ 123 124#ifdef HAVE_ENDIAN_H 125 #include <endian.h> 126#elif defined(HAVE_SYS_ENDIAN_H) 127 #include <sys/endian.h> 128#elif defined(HAVE_MACHINE_ENDIAN_H) 129 #include <machine/endian.h> 130#elif defined(__sun) 131 #include <sys/byteorder.h> 132 #ifndef LITTLE_ENDIAN 133 #define LITTLE_ENDIAN 1234 134 #endif 135 #ifndef BIG_ENDIAN 136 #define BIG_ENDIAN 4321 137 #endif 138 #ifdef _LITTLE_ENDIAN 139 #define BYTE_ORDER LITTLE_ENDIAN 140 #else 141 #define BYTE_ORDER BIG_ENDIAN 142 #endif 143#endif 144 145#ifndef BYTE_ORDER 146 147#ifndef LITTLE_ENDIAN 148 #define LITTLE_ENDIAN 1234 149#endif 150#ifndef BIG_ENDIAN 151 #define BIG_ENDIAN 4321 152#endif 153 154#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \ 155 defined(__BIG_ENDIAN__) || \ 156 defined(__ARMEB__) || \ 157 defined(__THUMBEB__) || \ 158 defined(__AARCH64EB__) || \ 159 defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) 160#define BYTE_ORDER BIG_ENDIAN 161#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \ 162 defined(__LITTLE_ENDIAN__) || \ 163 defined(__ARMEL__) || \ 164 defined(__THUMBEL__) || \ 165 defined(__AARCH64EL__) || \ 166 defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) 167#define BYTE_ORDER LITTLE_ENDIAN 168#else 169#error "I don't know what architecture this is!" 170#endif 171 172#endif /* BYTE_ORDER */ 173 174#define RSPAMD_SHAREDIR "${SHAREDIR}" 175#define RSPAMD_CONFDIR "${CONFDIR}" 176#define RSPAMD_LOCAL_CONFDIR "${LOCAL_CONFDIR}" 177#define RSPAMD_RUNDIR "${RUNDIR}" 178#define RSPAMD_LOGDIR "${LOGDIR}" 179#define RSPAMD_DBDIR "${DBDIR}" 180#define RSPAMD_PLUGINSDIR "${PLUGINSDIR}" 181#define RSPAMD_LUALIBDIR "${LUALIBDIR}" 182#define RSPAMD_RULESDIR "${RULESDIR}" 183#define RSPAMD_WWWDIR "${WWWDIR}" 184#define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}" 185#define RSPAMD_LIBDIR "${RSPAMD_LIBDIR}" 186 187#define RSPAMD_VERSION_MAJOR "${RSPAMD_VERSION_MAJOR}" 188#define RSPAMD_VERSION_MINOR "${RSPAMD_VERSION_MINOR}" 189 190#define RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR_NUM} 191#define RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR_NUM} 192 193#define RSPAMD_VERSION_BRANCH "${RSPAMD_VERSION_MAJOR}" 194 195#if defined(GIT_VERSION) && GIT_VERSION == 1 196# define RVERSION "${RSPAMD_VERSION}" 197# define RSPAMD_VERSION_FULL "${RSPAMD_VERSION}_${RSPAMD_ID}" 198# define RID "${RSPAMD_ID}" 199# define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}00${RSPAMD_ID}ULL 200#else 201# define RSPAMD_VERSION_FULL "${RSPAMD_VERSION}" 202# define RVERSION "${RSPAMD_VERSION}" 203# define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}000000000ULL 204# define RID "release" 205#endif 206 207#define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}" 208 209#define MODULES_NUM ${RSPAMD_MODULES_NUM} 210 211/* sys/types */ 212#ifdef HAVE_SYS_TYPES_H 213#include <sys/types.h> 214#endif 215 216/* cdefs */ 217#ifdef HAVE_SYS_CDEFS_H 218#include <sys/cdefs.h> 219#endif 220 221/* sys/param */ 222#ifdef HAVE_SYS_PARAM_H 223#include <sys/param.h> 224#endif 225 226/* stdint */ 227#ifdef HAVE_STDINT_H 228#include <stdint.h> 229#elif defined(HAVE_INTTYPES_H) 230#include <inttypes.h> 231#endif 232 233/* stdbool */ 234#ifdef HAVE_STDBOOL_H 235#include <stdbool.h> 236#endif 237 238/* stdlib */ 239#ifdef HAVE_STDLIB_H 240#include <stdlib.h> 241#endif 242 243/* stdio */ 244#ifdef HAVE_STDIO_H 245#include <stdio.h> 246#endif 247 248/* time */ 249#ifdef HAVE_TIME_H 250#include <time.h> 251#endif 252 253/* string */ 254#ifdef HAVE_STRING_H 255#include <string.h> 256#endif 257 258#ifdef HAVE_STRINGS_H 259#include <strings.h> 260#endif 261 262#include <errno.h> 263 264#include <glib.h> 265#include <gmodule.h> 266 267#ifdef GLIB_RE_COMPAT 268#include "gregex.h" 269#endif 270#ifdef GLIB_UNISCRIPT_COMPAT 271#include "guniscript.h" 272#endif 273#ifdef GLIB_COMPAT 274#include "gchecksum.h" 275#endif 276 277#if (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 14) 278typedef off_t goffset; 279#endif 280 281#ifndef PARAM_H_HAS_BITSET 282/* Bit map related macros. */ 283#ifndef NBBY 284# define NBBY 8 /* number of bits in a byte */ 285#endif 286#define setbit(a, \ 287 i) (((unsigned char *)(a))[(i) / NBBY] |= 1 << ((i) % NBBY)) 288#define clrbit(a, \ 289 i) (((unsigned char *)(a))[(i) / NBBY] &= ~(1 << ((i) % NBBY))) 290#define isset(a,i) \ 291 (((const unsigned char *)(a))[(i) / NBBY] & (1 << ((i) % NBBY))) 292#define isclr(a,i) \ 293 ((((const unsigned char *)(a))[(i) / NBBY] & (1 << ((i) % NBBY))) == 0) 294#endif 295 296#ifdef _MSC_VER 297# define RSPAMD_PACKED(name) \ 298 __pragma(pack(push, 1)) struct name __pragma(pack(pop)) 299#elif defined(__GNUC__) 300# define RSPAMD_PACKED(name) struct __attribute__((packed)) name 301#else 302# define RSPAMD_PACKED(name) struct name 303#endif 304 305#ifndef RSPAMD_ALIGNED 306#if defined(_MSC_VER) 307# define RSPAMD_ALIGNED(x) __declspec(align(x)) 308# define RSPAMD_OPTIMIZE(x) 309# define RSPAMD_ALWAYS_INLINE 310#elif defined(__GNUC__) 311# define RSPAMD_ALIGNED(x) __attribute__((aligned(x))) 312# define RSPAMD_ALWAYS_INLINE __attribute__((always_inline)) 313#ifndef __clang__ 314# define RSPAMD_OPTIMIZE(x) __attribute__((__optimize__ (x))) 315#else 316# define RSPAMD_OPTIMIZE(x) 317#endif 318#else 319# define RSPAMD_ALIGNED(x) 320# define RSPAMD_OPTIMIZE(x) 321# define RSPAMD_ALWAYS_INLINE 322#endif 323#endif 324 325#ifndef __cplusplus 326# ifdef G_ALIGNOF 327# define RSPAMD_ALIGNOF G_ALIGNOF 328# else 329# define RSPAMD_ALIGNOF(t) _Alignof(t) 330# endif 331#else 332/* glib G_ALIGNOF nor C11 _Alignof are not good enough for C++, nuff said... */ 333# define RSPAMD_ALIGNOF(t) alignof(t) 334#endif 335 336/* Address sanitizer */ 337#ifdef __clang__ 338# if __has_feature(address_sanitizer) 339/* emulate gcc's __SANITIZE_ADDRESS__ flag */ 340# define __SANITIZE_ADDRESS__ 341# define RSPAMD_NO_SANITIZE \ 342 __attribute__((no_sanitize("address", "hwaddress"))) 343# else 344# define RSPAMD_NO_SANITIZE 345# endif 346#elif defined(__GNUC__) 347/* GCC based */ 348# if defined(__has_attribute) 349# if __has_attribute(__no_sanitize_address__) 350# define RSPAMD_NO_SANITIZE __attribute__((no_sanitize_address)) 351# else 352# define RSPAMD_NO_SANITIZE 353# endif 354# else 355# define RSPAMD_NO_SANITIZE 356# endif 357#else 358# define RSPAMD_NO_SANITIZE 359#endif 360 361 362#ifndef BITSPERBYTE 363# define BITSPERBYTE (NBBY * sizeof (char)) 364#endif 365#ifndef NBYTES 366# define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) 367#endif 368 369 370#ifdef __cplusplus 371extern "C" { 372#endif 373extern uint64_t ottery_rand_uint64(void); 374#define UCL_RANDOM_FUNCTION ottery_rand_uint64() 375#ifdef __cplusplus 376} 377#endif 378 379 380/* Disable slab allocator if jemalloc is already in the system */ 381#if defined(WITH_JEMALLOC) || defined(__FreeBSD__) || \ 382 (defined(__NetBSD__) && __NetBSD_Version__ >= 500000000) 383#if 0 384 #define g_slice_alloc(sz) g_malloc(sz) 385 #define g_slice_alloc0(sz) g_malloc0(sz) 386 #define g_slice_free1(sz, p) g_free(p) 387#endif 388#endif 389 390#ifdef __cplusplus 391 #define RSPAMD_CONSTRUCTOR(f) \ 392 static void f(void); \ 393 struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \ 394 static void f(void) 395#else 396#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 397 #define RSPAMD_CONSTRUCTOR(f) \ 398 static void f(void) __attribute__((constructor)); \ 399 static void f(void) 400 #define RSPAMD_DESTRUCTOR(f) \ 401 static void f(void) __attribute__((destructor)); \ 402 static void f(void) 403#else 404 /* In fact, everything else is not supported ¯\_(ツ)_/¯ */ 405 #error incompatible compiler found, need gcc > 2.7 or clang 406#endif 407#endif /* __cplusplus */ 408 409#ifdef __GNUC__ 410#define RSPAMD_CONST_FUNCTION __attribute__ ((const)) 411#else 412#define RSPAMD_CONST_FUNCTION 413#endif 414 415#ifdef __GNUC__ 416#define RSPAMD_UNREACHABLE __builtin_unreachable() 417#else 418#define RSPAMD_UNREACHABLE abort() 419#endif 420 421#define HAVE_OPENSSL 1 422#define HAVE_MATH_H 1 423 424 425#endif 426