Rapid spam filtering system https://rspamd.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
11 KiB

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