DEPENDS ${RAGEL_DEPENDS}
COMPILE_FLAGS -G2
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ip_parser.rl.c)
+# Fucking cmake...
+FOREACH(_GEN ${LIBSERVER_GENERATED})
+ set_source_files_properties(${_GEN} PROPERTIES GENERATED TRUE)
+ENDFOREACH()
######################### LINK SECTION ###############################
IF(ENABLE_STATIC MATCHES "ON")
"${RAGEL_ragel_smtp_ip_OUTPUTS}")
ENDIF()
+FOREACH(_DEP ${LIBSERVER_DEPENDS})
+ ADD_DEPENDENCIES(rspamd-server "${_DEP}")
+ENDFOREACH()
+
TARGET_LINK_LIBRARIES(rspamd-server rspamd-http-parser)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-fpconv)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb)
# Librspamd-server
SET(RSPAMD_SERVER ${LIBRSPAMDSERVERSRC} PARENT_SCOPE)
+SET(LIBSERVER_DEPENDS "${LIBCSS_DEPENDS}" PARENT_SCOPE)
+SET(LIBSERVER_GENERATED "${LIBCSS_GENERATED}" PARENT_SCOPE)
+SET(RAGEL_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/css_syntax.rl")
+RAGEL_TARGET(ragel_css_selector_parser
+ INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/css_selector_parser.rl
+ DEPENDS ${RAGEL_DEPENDS}
+ COMPILE_FLAGS -G2
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/css_selector_parser.rl.cxx)
+RAGEL_TARGET(ragel_css_rule_parser
+ INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/css_rule_parser.rl
+ DEPENDS ${RAGEL_DEPENDS}
+ COMPILE_FLAGS -G2
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/css_rule_parser.rl.cxx)
+
SET(LIBCSSSRC "${CMAKE_CURRENT_SOURCE_DIR}/css.cxx"
"${CMAKE_CURRENT_SOURCE_DIR}/css_property.cxx"
"${CMAKE_CURRENT_SOURCE_DIR}/css_value.cxx"
"${CMAKE_CURRENT_SOURCE_DIR}/css_selector.cxx"
- PARENT_SCOPE)
\ No newline at end of file
+ "${RAGEL_ragel_css_selector_parser_OUTPUTS}"
+ "${RAGEL_ragel_css_rule_parser_OUTPUTS}"
+ PARENT_SCOPE)
+SET(LIBCSS_DEPENDS "ragel_css_selector_parser;ragel_css_rule_parser" PARENT_SCOPE)
+SET(LIBCSS_GENERATED
+ "${RAGEL_ragel_css_selector_parser_OUTPUTS};${RAGEL_ragel_css_rule_parser_OUTPUTS}" PARENT_SCOPE)
\ No newline at end of file
#include "css.h"
#include "css.hxx"
+#include "css_style.hxx"
+
+rspamd_css
+rspamd_css_parse_style (const guchar *begin, gsize len, GError **err)
+{
+ rspamd::css::css_style_sheet *style = nullptr;
+
+
+ return reinterpret_cast<rspamd_css>(style);
+}
+
+namespace rspamd::css {
+
+class css_style_sheet::impl {
+
+};
+
+css_style_sheet::css_style_sheet () : pimpl(new impl) {}
+css_style_sheet::~css_style_sheet () {}
+
+}
\ No newline at end of file
#ifndef RSPAMD_CSS_H
#define RSPAMD_CSS_H
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef void * rspamd_css;
+
+rspamd_css rspamd_css_parse_style (const guchar *begin, gsize len, GError **err);
+#ifdef __cplusplus
+}
+#endif
+
#endif //RSPAMD_CSS_H
#define RSPAMD_CSS_HXX
#include <string>
+#include <memory>
namespace rspamd::css {
-struct css_element {
-
+class css_style_sheet {
+public:
+ css_style_sheet();
+ ~css_style_sheet(); /* must be declared separately due to pimpl */
+private:
+ class impl;
+ std::unique_ptr<impl> pimpl;
};
}
size_t inlen);
};
+
}
/* Make properties hashable */
/* Constructors */
css_rule(css_rule &&other) = default;
explicit css_rule(css_property &&prop, css_values_vec &&values) :
- prop(prop), values(values) {}
+ prop(prop), values(std::forward<css_values_vec>(values)) {}
explicit css_rule(css_property &&prop) : prop(prop), values{} {}
/* Methods */
void add_value(std::unique_ptr<css_value> &&value) {
--- /dev/null
+%%{
+ machine css_parser;
+ alphtype unsigned char;
+ include css_syntax "css_syntax.rl";
+
+ main := declaration;
+}%%
+
+%% write data;
+
+#include <cstddef>
+
+namespace rspamd::css {
+
+int
+foo (const unsigned char *data, std::size_t len)
+{
+ const unsigned char *p = data, *pe = data + len, *eof;
+ int cs;
+
+ %% write init;
+ %% write exec;
+
+ return cs;
+}
+
+}
\ No newline at end of file
--- /dev/null
+%%{
+ machine css_parser;
+ alphtype unsigned char;
+ include css_syntax "css_syntax.rl";
+
+ main := selectors_group;
+}%%
+
+%% write data;
+
+#include <cstddef>
+
+namespace rspamd::css {
+
+int
+parse_css_selector (const unsigned char *data, std::size_t len)
+{
+ const unsigned char *p = data, *pe = data + len, *eof;
+ int cs;
+
+ %% write init;
+ %% write exec;
+
+ return cs;
+}
+
+}
\ No newline at end of file
*/
class css_style {
public:
- css_style(const std::shared_ptr<css_style> &_parent) : parent(_parent) {
+ /* Make class trivial */
+ css_style (const css_style &other) = default;
+
+ css_style (const std::shared_ptr<css_style> &_parent) : parent(_parent) {
propagate_from_parent ();
}
- css_style(const std::shared_ptr<css_style> &_parent,
+ css_style (const std::shared_ptr<css_style> &_parent,
const std::vector<std::shared_ptr<css_selector> > &_selectors) : parent(_parent) {
- selectors.reserve(_selectors.size());
+ selectors.reserve (_selectors.size ());
for (const auto &sel_ptr : _selectors) {
- selectors.emplace_back(sel_ptr);
+ selectors.emplace_back (sel_ptr);
}
propagate_from_parent ();