#include "css.hxx"
#include "contrib/robin-hood/robin_hood.h"
#include "css_parser.hxx"
+/* Keep unit tests implementation here (it'll possibly be moved outside one day) */
#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest/doctest.h"
+static void
+rspamd_css_dtor(void *p)
+{
+ rspamd::css::css_style_sheet *style =
+ reinterpret_cast<rspamd::css::css_style_sheet *>(p);
+
+ delete style;
+}
+
rspamd_css
-rspamd_css_parse_style (rspamd_mempool_t *pool, const guchar *begin, gsize len,
+rspamd_css_parse_style(rspamd_mempool_t *pool, const guchar *begin, gsize len,
GError **err)
{
auto parse_res = rspamd::css::parse_css(pool, {(const char* )begin, len});
if (parse_res.has_value()) {
- return reinterpret_cast<rspamd_css>(parse_res.value().release());
+ /*
+ * Detach style pointer from the unique_ptr as it will be managed by
+ * C memory pool
+ */
+ auto *detached_style = reinterpret_cast<rspamd_css>(parse_res.value().release());
+ rspamd_mempool_add_destructor(pool, rspamd_css_dtor, (void *)detached_style);
+ return detached_style;
}
else {
g_set_error(err, g_quark_from_static_string("css"),
state = selector_process_state::selector_ident_consumed;
break;
default:
- msg_debug_css("cannot consume more of a selector, invalid parser token: %*s; expected start",
+ msg_debug_css("cannot consume more of a selector, invalid parser token: %s; expected start",
next_tok.token_type_str());
can_continue = false;
break;
state = selector_process_state::selector_ident_consumed;
}
else {
- msg_debug_css("cannot consume more of a selector, invalid parser token: %*s; expected ident",
+ msg_debug_css("cannot consume more of a selector, invalid parser token: %s; expected ident",
next_tok.token_type_str());
can_continue = false;
}
guint mod_id,
const gchar *module, guint64 id,
const gchar *function, const gchar *fmt, ...);
+gboolean rspamd_logger_need_log (rspamd_logger_t *rspamd_log,
+ GLogLevelFlags log_level,
+ guint module_id);
/**
* Function with variable number of arguments support that uses static default logger