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.

lua_common.h 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. #ifndef RSPAMD_LUA_H
  2. #define RSPAMD_LUA_H
  3. #include "config.h"
  4. /* Lua headers do not have __cplusplus guards... */
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include <lua.h>
  9. #include <lauxlib.h>
  10. #include <lualib.h>
  11. #ifdef WITH_LUAJIT
  12. #include <luajit.h>
  13. #endif
  14. #ifdef __cplusplus
  15. }
  16. #endif
  17. #include <stdbool.h>
  18. #include "rspamd.h"
  19. #include "ucl.h"
  20. #include "lua_ucl.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #ifndef lua_open
  25. #define lua_open() luaL_newstate ()
  26. #endif
  27. #ifndef luaL_reg
  28. #define luaL_reg luaL_Reg
  29. #endif
  30. #define LUA_ENUM(L, name, val) \
  31. lua_pushlstring (L, # name, sizeof(# name) - 1); \
  32. lua_pushinteger (L, val); \
  33. lua_settable (L, -3);
  34. #if LUA_VERSION_NUM > 501 && !defined LUA_COMPAT_MODULE
  35. static inline void
  36. luaL_register (lua_State *L, const gchar *name, const struct luaL_reg *methods)
  37. {
  38. if (name != NULL) {
  39. lua_newtable (L);
  40. }
  41. luaL_setfuncs (L, methods, 0);
  42. if (name != NULL) {
  43. lua_pushvalue (L, -1);
  44. lua_setglobal (L, name);
  45. }
  46. }
  47. #endif
  48. #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
  49. /* Special hack to work with moonjit of specific version */
  50. #if !defined(MOONJIT_VERSION) && (!defined(LUAJIT_VERSION_NUM) || LUAJIT_VERSION_NUM != 20200)
  51. static inline int lua_absindex (lua_State *L, int i) {
  52. if (i < 0 && i > LUA_REGISTRYINDEX)
  53. i += lua_gettop(L) + 1;
  54. return i;
  55. }
  56. #endif
  57. #endif
  58. /* Interface definitions */
  59. #define LUA_FUNCTION_DEF(class, name) static int lua_##class##_##name (lua_State * L)
  60. #define LUA_PUBLIC_FUNCTION_DEF(class, name) int lua_##class##_##name (lua_State * L)
  61. #define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name }
  62. extern const luaL_reg null_reg[];
  63. #define RSPAMD_LUA_API_VERSION 12
  64. /**
  65. * Lua IP address structure
  66. */
  67. struct rspamd_lua_ip {
  68. rspamd_inet_addr_t *addr;
  69. };
  70. #define RSPAMD_TEXT_FLAG_OWN (1u << 0u)
  71. #define RSPAMD_TEXT_FLAG_MMAPED (1u << 1u)
  72. #define RSPAMD_TEXT_FLAG_WIPE (1u << 2u)
  73. #define RSPAMD_TEXT_FLAG_SYSMALLOC (1u << 3u)
  74. #define RSPAMD_TEXT_FLAG_FAKE (1u << 4u)
  75. #define RSPAMD_TEXT_FLAG_BINARY (1u << 5u)
  76. struct rspamd_lua_text {
  77. const gchar *start;
  78. guint len;
  79. guint flags;
  80. };
  81. struct rspamd_lua_url {
  82. struct rspamd_url *url;
  83. };
  84. struct rspamd_lua_regexp {
  85. rspamd_regexp_t *re;
  86. gchar *module;
  87. gchar *re_pattern;
  88. gint re_flags;
  89. };
  90. struct rspamd_map;
  91. struct lua_map_callback_data;
  92. struct radix_tree_compressed;
  93. struct rspamd_mime_header;
  94. enum rspamd_lua_map_type {
  95. RSPAMD_LUA_MAP_RADIX = 0,
  96. RSPAMD_LUA_MAP_SET,
  97. RSPAMD_LUA_MAP_HASH,
  98. RSPAMD_LUA_MAP_REGEXP,
  99. RSPAMD_LUA_MAP_REGEXP_MULTIPLE,
  100. RSPAMD_LUA_MAP_CALLBACK,
  101. RSPAMD_LUA_MAP_CDB,
  102. RSPAMD_LUA_MAP_UNKNOWN,
  103. };
  104. struct rspamd_lua_map {
  105. struct rspamd_map *map;
  106. enum rspamd_lua_map_type type;
  107. guint flags;
  108. union {
  109. struct rspamd_radix_map_helper *radix;
  110. struct rspamd_hash_map_helper *hash;
  111. struct rspamd_regexp_map_helper *re_map;
  112. struct rspamd_cdb_map_helper *cdb_map;
  113. struct lua_map_callback_data *cbdata;
  114. } data;
  115. };
  116. struct rspamd_lua_cached_entry {
  117. gint ref;
  118. guint id;
  119. };
  120. struct rspamd_lua_upstream {
  121. struct upstream *up;
  122. gint upref;
  123. };
  124. /* Common utility functions */
  125. /**
  126. * Create and register new class
  127. */
  128. void rspamd_lua_new_class (lua_State *L,
  129. const gchar *classname,
  130. const struct luaL_reg *methods);
  131. /**
  132. * Set class name for object at @param objidx position
  133. */
  134. void rspamd_lua_setclass (lua_State *L, const gchar *classname, gint objidx);
  135. /**
  136. * Pushes the metatable for specific class on top of the stack
  137. * @param L
  138. * @param classname
  139. */
  140. void rspamd_lua_class_metatable (lua_State *L, const gchar *classname);
  141. /**
  142. * Adds a new field to the class (metatable) identified by `classname`
  143. * @param L
  144. * @param classname
  145. * @param meth
  146. */
  147. void rspamd_lua_add_metamethod (lua_State *L, const gchar *classname,
  148. luaL_Reg *meth);
  149. /**
  150. * Set index of table to value (like t['index'] = value)
  151. */
  152. void rspamd_lua_table_set (lua_State *L, const gchar *index, const gchar *value);
  153. /**
  154. * Get string value of index in a table (return t['index'])
  155. */
  156. const gchar *rspamd_lua_table_get (lua_State *L, const gchar *index);
  157. /**
  158. * Convert classname to string
  159. */
  160. gint rspamd_lua_class_tostring (lua_State *L);
  161. /**
  162. * Check whether the argument at specified index is of the specified class
  163. */
  164. gpointer rspamd_lua_check_class (lua_State *L, gint index, const gchar *name);
  165. /**
  166. * Initialize lua and bindings
  167. */
  168. lua_State *rspamd_lua_init (bool wipe_mem);
  169. /**
  170. * Close lua_state and free remainders
  171. * @param L
  172. */
  173. void rspamd_lua_close (lua_State *L);
  174. void rspamd_lua_start_gc (struct rspamd_config *cfg);
  175. /**
  176. * Sets field in a global variable
  177. * @param L
  178. * @param global_name
  179. * @param field_name
  180. * @param new_elt
  181. */
  182. void
  183. rspamd_plugins_table_push_elt (lua_State *L, const gchar *field_name,
  184. const gchar *new_elt);
  185. /**
  186. * Load and initialize lua plugins
  187. */
  188. gboolean
  189. rspamd_init_lua_filters (struct rspamd_config *cfg, bool force_load, bool strict);
  190. /**
  191. * Push lua ip address
  192. */
  193. void rspamd_lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr);
  194. /**
  195. * Push rspamd task structure to lua
  196. */
  197. void rspamd_lua_task_push (lua_State *L, struct rspamd_task *task);
  198. /**
  199. * Return lua ip structure at the specified address
  200. */
  201. struct rspamd_lua_ip *lua_check_ip (lua_State *L, gint pos);
  202. struct rspamd_lua_text *lua_check_text (lua_State *L, gint pos);
  203. /**
  204. * Checks for a text or a string. In case of string a pointer to static structure is returned.
  205. * So it should not be reused or placed to Lua stack anyhow!
  206. * However, you can use this function up to 4 times and have distinct static structures
  207. * @param L
  208. * @param pos
  209. * @return
  210. */
  211. struct rspamd_lua_text *lua_check_text_or_string (lua_State *L, gint pos);
  212. /* Creates and *pushes* new rspamd text, data is copied if RSPAMD_TEXT_FLAG_OWN is in flags*/
  213. struct rspamd_lua_text *lua_new_text (lua_State *L, const gchar *start,
  214. gsize len, gboolean own);
  215. /**
  216. * Checks if a text has binary characters (non ascii and non-utf8 characters)
  217. * @param t
  218. * @return
  219. */
  220. bool lua_is_text_binary(struct rspamd_lua_text *t);
  221. struct rspamd_lua_regexp* lua_check_regexp (lua_State *L, gint pos);
  222. struct rspamd_lua_upstream* lua_check_upstream(lua_State *L, int pos);
  223. enum rspamd_lua_task_header_type {
  224. RSPAMD_TASK_HEADER_PUSH_SIMPLE = 0,
  225. RSPAMD_TASK_HEADER_PUSH_RAW,
  226. RSPAMD_TASK_HEADER_PUSH_FULL,
  227. RSPAMD_TASK_HEADER_PUSH_COUNT,
  228. RSPAMD_TASK_HEADER_PUSH_HAS,
  229. };
  230. gint rspamd_lua_push_header (lua_State *L,
  231. struct rspamd_mime_header *h,
  232. enum rspamd_lua_task_header_type how);
  233. /**
  234. * Push specific header to lua
  235. */
  236. gint rspamd_lua_push_header_array (lua_State *L,
  237. const gchar *name,
  238. struct rspamd_mime_header *rh,
  239. enum rspamd_lua_task_header_type how,
  240. gboolean strong);
  241. /**
  242. * Check for task at the specified position
  243. */
  244. struct rspamd_task *lua_check_task (lua_State *L, gint pos);
  245. struct rspamd_task *lua_check_task_maybe (lua_State *L, gint pos);
  246. struct rspamd_lua_map *lua_check_map (lua_State *L, gint pos);
  247. /**
  248. * Push ip address from a string (nil is pushed if a string cannot be converted)
  249. */
  250. void rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str);
  251. /**
  252. * Create type error
  253. */
  254. int rspamd_lua_typerror (lua_State *L, int narg, const char *tname);
  255. /**
  256. * Open libraries functions
  257. */
  258. /**
  259. * Add preload function
  260. */
  261. void rspamd_lua_add_preload (lua_State *L, const gchar *name, lua_CFunction func);
  262. void luaopen_task (lua_State *L);
  263. void luaopen_config (lua_State *L);
  264. void luaopen_map (lua_State *L);
  265. void luaopen_trie (lua_State *L);
  266. void luaopen_textpart (lua_State *L);
  267. void luaopen_mimepart (lua_State *L);
  268. void luaopen_image (lua_State *L);
  269. void luaopen_url (lua_State *L);
  270. void luaopen_classifier (lua_State *L);
  271. void luaopen_statfile (lua_State *L);
  272. void luaopen_regexp (lua_State *L);
  273. void luaopen_cdb (lua_State *L);
  274. void luaopen_xmlrpc (lua_State *L);
  275. void luaopen_http (lua_State *L);
  276. void luaopen_redis (lua_State *L);
  277. void luaopen_upstream (lua_State *L);
  278. void luaopen_mempool (lua_State *L);
  279. void luaopen_dns_resolver (lua_State *L);
  280. void luaopen_rsa (lua_State *L);
  281. void luaopen_ip (lua_State *L);
  282. void luaopen_expression (lua_State *L);
  283. void luaopen_logger (lua_State *L);
  284. void luaopen_text (lua_State *L);
  285. void luaopen_util (lua_State *L);
  286. void luaopen_tcp (lua_State *L);
  287. void luaopen_html (lua_State *L);
  288. void luaopen_sqlite3 (lua_State *L);
  289. void luaopen_cryptobox (lua_State *L);
  290. void luaopen_dns (lua_State *L);
  291. void luaopen_udp (lua_State *L);
  292. void luaopen_worker (lua_State *L);
  293. void luaopen_kann (lua_State *L);
  294. void luaopen_spf (lua_State *L);
  295. void luaopen_tensor (lua_State *L);
  296. void luaopen_parsers (lua_State *L);
  297. void rspamd_lua_dostring (const gchar *line);
  298. double rspamd_lua_normalize (struct rspamd_config *cfg,
  299. long double score,
  300. void *params);
  301. /* Config file functions */
  302. void rspamd_lua_post_load_config (struct rspamd_config *cfg);
  303. gboolean rspamd_lua_handle_param (struct rspamd_task *task,
  304. gchar *mname,
  305. gchar *optname,
  306. enum lua_var_type expected_type,
  307. gpointer *res);
  308. gboolean rspamd_lua_check_condition (struct rspamd_config *cfg,
  309. const gchar *condition);
  310. void rspamd_lua_dumpstack (lua_State *L);
  311. /* Set lua path according to the configuration */
  312. void rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj,
  313. GHashTable *vars);
  314. /* Set some lua globals */
  315. gboolean rspamd_lua_set_env (lua_State *L, GHashTable *vars, char **lua_env,
  316. GError **err);
  317. void rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L);
  318. struct memory_pool_s *rspamd_lua_check_mempool (lua_State *L, gint pos);
  319. struct rspamd_config *lua_check_config (lua_State *L, gint pos);
  320. struct rspamd_async_session *lua_check_session (lua_State *L, gint pos);
  321. struct ev_loop *lua_check_ev_base (lua_State *L, gint pos);
  322. struct rspamd_dns_resolver *lua_check_dns_resolver (lua_State *L, gint pos);
  323. struct rspamd_lua_url *lua_check_url (lua_State * L, gint pos);
  324. enum rspamd_lua_parse_arguments_flags {
  325. RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT = 0,
  326. RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING,
  327. };
  328. /**
  329. * Extract an arguments from lua table according to format string. Supported arguments are:
  330. * [*]key=S|I|N|B|V|U{a-z};[key=...]
  331. * - S - const char *
  332. * - I - gint64_t
  333. * - i - int32_t
  334. * - N - double
  335. * - B - gboolean
  336. * - V - size_t + const char *
  337. * - U{classname} - userdata of the following class (stored in gpointer)
  338. * - F - function
  339. * - O - ucl_object_t *
  340. * - D - same as N but argument is set to NAN not to 0.0
  341. * - u{classname} - userdata of the following class (stored directly)
  342. *
  343. * If any of keys is prefixed with `*` then it is treated as required argument
  344. * @param L lua state
  345. * @param pos at which pos start extraction
  346. * @param err error pointer
  347. * @param how extraction type (IGNORE_MISSING means that default values will not be set)
  348. * @param extraction_pattern static pattern
  349. * @return TRUE if a table has been parsed
  350. */
  351. gboolean rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
  352. GError **err,
  353. enum rspamd_lua_parse_arguments_flags how,
  354. const gchar *extraction_pattern, ...);
  355. gint rspamd_lua_traceback (lua_State *L);
  356. /**
  357. * Returns stack trace as a string. Caller should clear memory.
  358. * @param L
  359. * @return
  360. */
  361. void rspamd_lua_get_traceback_string (lua_State *L, luaL_Buffer *buf);
  362. /**
  363. * Returns size of table at position `tbl_pos`
  364. */
  365. guint rspamd_lua_table_size (lua_State *L, gint tbl_pos);
  366. void lua_push_emails_address_list (lua_State *L, GPtrArray *addrs, int flags);
  367. #define TRACE_POINTS 6
  368. struct lua_logger_trace {
  369. gint cur_level;
  370. gconstpointer traces[TRACE_POINTS];
  371. };
  372. enum lua_logger_escape_type {
  373. LUA_ESCAPE_NONE = (0u),
  374. LUA_ESCAPE_UNPRINTABLE = (1u << 0u),
  375. LUA_ESCAPE_NEWLINES = (1u << 1u),
  376. LUA_ESCAPE_8BIT = (1u << 2u),
  377. };
  378. #define LUA_ESCAPE_LOG (LUA_ESCAPE_UNPRINTABLE|LUA_ESCAPE_NEWLINES)
  379. #define LUA_ESCAPE_ALL (LUA_ESCAPE_UNPRINTABLE|LUA_ESCAPE_NEWLINES|LUA_ESCAPE_8BIT)
  380. /**
  381. * Log lua object to string
  382. * @param L
  383. * @param pos
  384. * @param outbuf
  385. * @param len
  386. * @return
  387. */
  388. gsize lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf,
  389. gsize len, struct lua_logger_trace *trace,
  390. enum lua_logger_escape_type esc_type);
  391. /**
  392. * Safely checks userdata to match specified class
  393. * @param L
  394. * @param pos
  395. * @param classname
  396. */
  397. void *rspamd_lua_check_udata (lua_State *L, gint pos, const gchar *classname);
  398. #define RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, pos, classname, type, dest) do { \
  399. type **_maybe_ptr = (type **)rspamd_lua_check_udata((L), (pos), (classname)); \
  400. if (_maybe_ptr == NULL) { \
  401. return luaL_error (L, "%s: invalid arguments; pos = %d; expected = %s", G_STRFUNC, (pos), (classname)); \
  402. } \
  403. (dest) = *(_maybe_ptr); \
  404. } while(0)
  405. /**
  406. * Safely checks userdata to match specified class
  407. * @param L
  408. * @param pos
  409. * @param classname
  410. */
  411. void *rspamd_lua_check_udata_maybe (lua_State *L, gint pos, const gchar *classname);
  412. /**
  413. * Call finishing script with the specified task
  414. * @param sc
  415. * @param task
  416. */
  417. void lua_call_finish_script (struct rspamd_config_cfg_lua_script *sc,
  418. struct rspamd_task *task);
  419. /**
  420. * Run post-load operations
  421. * @param L
  422. * @param cfg
  423. * @param ev_base
  424. */
  425. void rspamd_lua_run_postloads (lua_State *L, struct rspamd_config *cfg,
  426. struct ev_loop *ev_base, struct rspamd_worker *w);
  427. void rspamd_lua_run_config_post_init (lua_State *L, struct rspamd_config *cfg);
  428. void rspamd_lua_run_config_unload (lua_State *L, struct rspamd_config *cfg);
  429. /**
  430. * Adds new destructor for a local function for specific pool
  431. * @param L
  432. * @param pool
  433. * @param ref
  434. */
  435. void rspamd_lua_add_ref_dtor (lua_State *L, rspamd_mempool_t *pool,
  436. gint ref);
  437. /**
  438. * Returns a lua reference from a function like string, e.g. `return function(...) end`
  439. * @param L
  440. * @param str
  441. * @return
  442. */
  443. gint rspamd_lua_function_ref_from_str (lua_State *L, const gchar *str, gsize slen,
  444. const gchar *modname, GError **err);
  445. /**
  446. * Tries to load some module using `require` and get some method from it
  447. * @param L
  448. * @param modname
  449. * @param funcname
  450. * @return TRUE if function exists in that module, the function is pushed in stack, otherwise stack is unchanged and FALSE is returned
  451. */
  452. gboolean rspamd_lua_require_function (lua_State *L, const gchar *modname,
  453. const gchar *funcname);
  454. /**
  455. * Tries to load redis server definition from ucl object specified
  456. * @param L
  457. * @param obj
  458. * @param cfg
  459. * @return
  460. */
  461. gboolean rspamd_lua_try_load_redis (lua_State *L, const ucl_object_t *obj,
  462. struct rspamd_config *cfg, gint *ref_id);
  463. struct rspamd_stat_token_s;
  464. /**
  465. * Pushes a single word into Lua
  466. * @param L
  467. * @param word
  468. */
  469. void rspamd_lua_push_full_word (lua_State *L, struct rspamd_stat_token_s *word);
  470. enum rspamd_lua_words_type {
  471. RSPAMD_LUA_WORDS_STEM = 0,
  472. RSPAMD_LUA_WORDS_NORM,
  473. RSPAMD_LUA_WORDS_RAW,
  474. RSPAMD_LUA_WORDS_FULL,
  475. RSPAMD_LUA_WORDS_MAX
  476. };
  477. /**
  478. * Pushes words (rspamd_stat_token_t) to Lua
  479. * @param L
  480. * @param words
  481. * @param how
  482. */
  483. gint rspamd_lua_push_words (lua_State *L, GArray *words,
  484. enum rspamd_lua_words_type how);
  485. /**
  486. * Returns newly allocated name for caller module name
  487. * @param L
  488. * @return
  489. */
  490. gchar *rspamd_lua_get_module_name (lua_State *L);
  491. /**
  492. * Call Lua function in a universal way. Arguments string:
  493. * - i - lua_integer, argument - gint64
  494. * - n - lua_number, argument - gdouble
  495. * - s - lua_string, argument - const gchar * (zero terminated)
  496. * - l - lua_lstring, argument - (size_t + const gchar *) pair
  497. * - u - lua_userdata, argument - (const char * + void *) - classname + pointer
  498. * - b - lua_boolean, argument - gboolean (not bool due to varargs promotion)
  499. * - f - lua_function, argument - int - position of the function on stack (not lua_registry)
  500. * - t - lua_text, argument - int - position of the lua_text on stack (not lua_registry)
  501. * @param L lua state
  502. * @param cbref LUA_REGISTRY reference
  503. * @param strloc where this function is called from
  504. * @param nret number of results (or LUA_MULTRET)
  505. * @param args arguments format string
  506. * @param err error to promote
  507. * @param ... arguments
  508. * @return true of pcall returned 0, false + err otherwise
  509. */
  510. bool rspamd_lua_universal_pcall (lua_State *L, gint cbref, const gchar* strloc,
  511. gint nret, const gchar *args, GError **err, ...);
  512. /**
  513. * Wrapper for lua_geti from lua 5.3
  514. * @param L
  515. * @param index
  516. * @param i
  517. * @return
  518. */
  519. #if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502
  520. gint rspamd_lua_geti (lua_State *L, int index, int i);
  521. #else
  522. #define rspamd_lua_geti lua_geti
  523. #endif
  524. /* Paths defs */
  525. #define RSPAMD_CONFDIR_INDEX "CONFDIR"
  526. #define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR"
  527. #define RSPAMD_RUNDIR_INDEX "RUNDIR"
  528. #define RSPAMD_DBDIR_INDEX "DBDIR"
  529. #define RSPAMD_LOGDIR_INDEX "LOGDIR"
  530. #define RSPAMD_PLUGINSDIR_INDEX "PLUGINSDIR"
  531. #define RSPAMD_SHAREDIR_INDEX "SHAREDIR"
  532. #define RSPAMD_RULESDIR_INDEX "RULESDIR"
  533. #define RSPAMD_LUALIBDIR_INDEX "LUALIBDIR"
  534. #define RSPAMD_WWWDIR_INDEX "WWWDIR"
  535. #define RSPAMD_PREFIX_INDEX "PREFIX"
  536. #define RSPAMD_VERSION_INDEX "VERSION"
  537. #ifdef WITH_LUA_TRACE
  538. extern ucl_object_t *lua_traces;
  539. #define LUA_TRACE_POINT do { \
  540. ucl_object_t *func_obj; \
  541. if (lua_traces == NULL) { lua_traces = ucl_object_typed_new (UCL_OBJECT); } \
  542. func_obj = (ucl_object_t *)ucl_object_lookup (lua_traces, G_STRFUNC); \
  543. if (func_obj == NULL) { \
  544. func_obj = ucl_object_typed_new (UCL_INT); \
  545. ucl_object_insert_key (lua_traces, func_obj, G_STRFUNC, 0, false); \
  546. } \
  547. func_obj->value.iv ++; \
  548. } while(0)
  549. #else
  550. #define LUA_TRACE_POINT do {} while(0)
  551. #endif
  552. #ifdef __cplusplus
  553. }
  554. #endif
  555. #endif /* RSPAMD_LUA_H */