summaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-08-16 14:20:15 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-08-16 14:20:15 +0100
commitef583245356015ce29961e0f7ffdb5880edc5fc2 (patch)
treec4c8aa3149da38f443a75bf63d2d33d0dab9a61c /src/lua
parent5ffee59dfce8b60669f93fc59c8304f9ec4703f7 (diff)
downloadrspamd-ef583245356015ce29961e0f7ffdb5880edc5fc2.tar.gz
rspamd-ef583245356015ce29961e0f7ffdb5880edc5fc2.zip
[Rework] More steps to do refactoring
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_cfg_file.c8
-rw-r--r--src/lua/lua_config.c16
-rw-r--r--src/lua/lua_util.c10
3 files changed, 17 insertions, 17 deletions
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index 0386c0969..75bc3806d 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 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
+ * 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,
@@ -124,7 +124,7 @@ void rspamd_lua_post_load_config(struct rspamd_config *cfg)
if (obj != NULL) {
ucl_object_sort_keys(obj, UCL_SORT_KEYS_DEFAULT);
- ucl_object_insert_key_merged(cfg->rcl_obj,
+ ucl_object_insert_key_merged(cfg->cfg_ucl_obj,
obj,
name,
strlen(name),
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 3342d18bd..a044827a7 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1044,7 +1044,7 @@ lua_config_get_all_opt(lua_State *L)
mname = luaL_checkstring(L, 2);
if (mname) {
- obj = ucl_obj_get_key(cfg->rcl_obj, mname);
+ obj = ucl_obj_get_key(cfg->cfg_ucl_obj, mname);
/* Flatten object */
if (obj != NULL && (ucl_object_type(obj) == UCL_OBJECT ||
ucl_object_type(obj) == UCL_ARRAY)) {
@@ -1114,8 +1114,8 @@ lua_config_get_ucl(lua_State *L)
lua_rawgeti(L, LUA_REGISTRYINDEX, cached->ref);
}
else {
- if (cfg->rcl_obj) {
- ucl_object_push_lua(L, cfg->rcl_obj, true);
+ if (cfg->cfg_ucl_obj) {
+ ucl_object_push_lua(L, cfg->cfg_ucl_obj, true);
lua_pushvalue(L, -1);
cached = rspamd_mempool_alloc(cfg->cfg_pool, sizeof(*cached));
cached->L = L;
@@ -1725,7 +1725,7 @@ lua_config_get_key(lua_State *L)
name = luaL_checklstring(L, 2, &namelen);
if (name && cfg) {
- val = ucl_object_lookup_len(cfg->rcl_obj, name, namelen);
+ val = ucl_object_lookup_len(cfg->cfg_ucl_obj, name, namelen);
if (val != NULL) {
ucl_object_push_lua(L, val, val->type != UCL_ARRAY);
}
@@ -4423,7 +4423,7 @@ lua_config_parse_rcl(lua_State *L)
GHashTable *excluded = g_hash_table_new_full(rspamd_str_hash, rspamd_str_equal,
g_free, NULL);
GError *err = NULL;
- struct rspamd_rcl_section *top;
+ struct rspamd_rcl_sections_map *top;
if (cfg) {
if (lua_istable(L, 2)) {
@@ -4439,12 +4439,12 @@ lua_config_parse_rcl(lua_State *L)
top = rspamd_rcl_config_init(cfg, excluded);
- if (!rspamd_rcl_parse(top, cfg, cfg, cfg->cfg_pool, cfg->rcl_obj, &err)) {
+ if (!rspamd_rcl_parse(top, cfg, cfg, cfg->cfg_pool, cfg->cfg_ucl_obj, &err)) {
lua_pushboolean(L, false);
lua_pushfstring(L, "failed to load config: %s", err->message);
g_error_free(err);
g_hash_table_unref(excluded);
- rspamd_rcl_section_free(top);
+ rspamd_rcl_sections_free(top);
return 2;
}
@@ -4454,7 +4454,7 @@ lua_config_parse_rcl(lua_State *L)
}
g_hash_table_unref(excluded);
- rspamd_rcl_section_free(top);
+ rspamd_rcl_sections_free(top);
lua_pushboolean(L, true);
return 1;
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 503dd8ffb..550e0a9ee 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 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
+ * 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,
@@ -882,10 +882,10 @@ lua_util_config_from_ucl(lua_State *L)
cfg = rspamd_config_new(RSPAMD_CONFIG_INIT_SKIP_LUA);
cfg->lua_state = L;
- cfg->rcl_obj = obj;
+ cfg->cfg_ucl_obj = obj;
top = rspamd_rcl_config_init(cfg, NULL);
- if (!rspamd_rcl_parse(top, cfg, cfg, cfg->cfg_pool, cfg->rcl_obj, &err)) {
+ if (!rspamd_rcl_parse(top, cfg, cfg, cfg->cfg_pool, cfg->cfg_ucl_obj, &err)) {
msg_err("rcl parse error: %s", err->message);
ucl_object_unref(obj);
lua_pushnil(L);