From 0e84ee1e726e12a264c244632b7f9d71059b2a54 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 1 Jun 2021 20:18:30 +0100 Subject: [PATCH] [Rework] Html: Forgot to add the internal include --- src/libserver/html/html.hxx | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/libserver/html/html.hxx diff --git a/src/libserver/html/html.hxx b/src/libserver/html/html.hxx new file mode 100644 index 000000000..c3f3830ec --- /dev/null +++ b/src/libserver/html/html.hxx @@ -0,0 +1,76 @@ +/*- + * Copyright 2021 Vsevolod Stakhov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RSPAMD_HTML_HXX +#define RSPAMD_HTML_HXX +#pragma once + +#include "config.h" +#include "libserver/url.h" +#include "libserver/html/html_tag.hxx" +#include "libserver/html/html.h" +#include "libserver/html/html_tags.h" + +#include +#include + +namespace rspamd::html { + +struct html_content { + struct rspamd_url *base_url = nullptr; + GNode *html_tags; + gint flags = 0; + guint total_tags = 0; + struct html_color bgcolor; + std::vector tags_seen; + std::vector images; + std::vector blocks; + std::vector> all_tags; + std::string parsed; + void *css_style; + + /* Preallocate and reserve all internal structures */ + html_content() { + html_tags = g_node_new(nullptr); + tags_seen.resize(N_TAGS, false); + blocks.reserve(128); + all_tags.reserve(128); + parsed.reserve(256); + /* Set white background color by default */ + bgcolor.d.comp.alpha = 0; + bgcolor.d.comp.r = 255; + bgcolor.d.comp.g = 255; + bgcolor.d.comp.b = 255; + bgcolor.valid = TRUE; + } + + static void html_content_dtor(void *ptr) { + delete html_content::from_ptr(ptr); + } + + static auto from_ptr(void *ptr) -> html_content * { + return static_cast(ptr); + } + +private: + ~html_content() { + g_node_destroy(html_tags); + } +}; + +} + +#endif //RSPAMD_HTML_HXX -- 2.39.5