From: Vsevolod Stakhov Date: Sat, 30 Apr 2022 11:24:55 +0000 (+0100) Subject: [Project] Move some more methods X-Git-Tag: 3.3~293^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2cda0d88a6c5832ea06c2ce102c4300938664d5c;p=thirdparty%2Frspamd.git [Project] Move some more methods --- diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx index 51b3909820..14fead7e49 100644 --- a/src/libserver/symcache/symcache_c.cxx +++ b/src/libserver/symcache/symcache_c.cxx @@ -286,6 +286,65 @@ rspamd_symcache_process_settings_elt(struct rspamd_symcache *cache, real_cache->process_settings_elt(elt); } +bool +rspamd_symcache_set_allowed_settings_ids(struct rspamd_symcache *cache, + const gchar *symbol, + const guint32 *ids, + guint nids) +{ + auto *real_cache = C_API_SYMCACHE(cache); + + auto *item = real_cache->get_item_by_name_mut(symbol, false); + + if (item == nullptr) { + return false; + } + + item->allowed_ids.set_ids(ids, nids, real_cache->get_pool()); + return true; +} + +bool +rspamd_symcache_set_forbidden_settings_ids(struct rspamd_symcache *cache, + const gchar *symbol, + const guint32 *ids, + guint nids) +{ + auto *real_cache = C_API_SYMCACHE(cache); + + auto *item = real_cache->get_item_by_name_mut(symbol, false); + + if (item == nullptr) { + return false; + } + + item->forbidden_ids.set_ids(ids, nids, real_cache->get_pool()); + return true; +} + +const guint32 * +rspamd_symcache_get_allowed_settings_ids(struct rspamd_symcache *cache, + const gchar *symbol, + guint *nids) +{ + auto *real_cache = C_API_SYMCACHE(cache); + + const auto *item = real_cache->get_item_by_name(symbol, false); + return item->allowed_ids.get_ids(*nids); + +} + +const guint32 * +rspamd_symcache_get_forbidden_settings_ids (struct rspamd_symcache *cache, + const gchar *symbol, + guint *nids) +{ + auto *real_cache = C_API_SYMCACHE(cache); + + const auto *item = real_cache->get_item_by_name(symbol, false); + return item->forbidden_ids.get_ids(*nids); +} + void rspamd_symcache_disable_all_symbols(struct rspamd_task *task, struct rspamd_symcache *_cache, diff --git a/src/libserver/symcache/symcache_id_list.hxx b/src/libserver/symcache/symcache_id_list.hxx index 444ac2079f..10a3ba2b7d 100644 --- a/src/libserver/symcache/symcache_id_list.hxx +++ b/src/libserver/symcache/symcache_id_list.hxx @@ -54,7 +54,7 @@ struct id_list { * @param nids output of the number of elements * @return */ - auto get_ids(std::size_t &nids) const -> const std::uint32_t * + auto get_ids(unsigned &nids) const -> const std::uint32_t * { if (data.dyn.e == -1) { /* Dynamic list */ diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index 4eb2cc0082..635dc63242 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -14,11 +14,11 @@ * limitations under the License. */ +#include "lua/lua_common.h" #include "symcache_internal.hxx" #include "symcache_item.hxx" #include "fmt/core.h" #include "libserver/task.h" -#include "lua/lua_common.h" namespace rspamd::symcache { @@ -56,7 +56,7 @@ auto cache_item::process_deps(const symcache &cache) -> void msg_debug_cache("process virtual dependency %s(%d) on %s(%d)", symbol.c_str(), dep.vid, vdit->symbol.c_str(), vdit->id); - std::size_t nids = 0; + unsigned nids = 0; /* Propagate ids */ msg_debug_cache("check id propagation for dependency %s from %s", diff --git a/src/libutil/cxx/locked_file.cxx b/src/libutil/cxx/locked_file.cxx index cda05a6c31..69644acbbe 100644 --- a/src/libutil/cxx/locked_file.cxx +++ b/src/libutil/cxx/locked_file.cxx @@ -1,7 +1,18 @@ -// -// Created by Vsevolod Stakhov on 02/04/2022. -// - +/*- + * Copyright 2022 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. + */ #include "locked_file.hxx" #include #include "libutil/util.h"