]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Move some more methods
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 30 Apr 2022 11:24:55 +0000 (12:24 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 30 Apr 2022 11:24:55 +0000 (12:24 +0100)
src/libserver/symcache/symcache_c.cxx
src/libserver/symcache/symcache_id_list.hxx
src/libserver/symcache/symcache_item.cxx
src/libutil/cxx/locked_file.cxx

index 51b39098201a2bbfff4dc32d328dfea72c9a7915..14fead7e4987777903093af90bd4a2f1daae58a2 100644 (file)
@@ -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,
index 444ac2079fae3b7f4597872ac46e7c994ce5ce35..10a3ba2b7d0d6e905e3c3b0e84a92aba96be2840 100644 (file)
@@ -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 */
index 4eb2cc00827af4b6ddbc801edaa7e3b3d7902d5e..635dc6324299cd124241ed16467e251c5aa5842f 100644 (file)
  * 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",
index cda05a6c3144d912b2e0eb775f583f5eb1bb2c88..69644acbbe0300e5358719420baaabf120498b52 100644 (file)
@@ -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 <fmt/core.h>
 #include "libutil/util.h"