aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-16 09:59:52 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-16 09:59:52 +0000
commit6bc5286496c43a0ee9f1a616507c7aa03e28450c (patch)
tree9a6ed4374aaf129777560ba58f608368fb8754df /src
parent153e64677902c1acc7a1e8ee21d5b634d8a65885 (diff)
downloadrspamd-6bc5286496c43a0ee9f1a616507c7aa03e28450c.tar.gz
rspamd-6bc5286496c43a0ee9f1a616507c7aa03e28450c.zip
Refactor UCL API
Diffstat (limited to 'src')
-rw-r--r--src/client/rspamc.c122
-rw-r--r--src/controller.c20
-rw-r--r--src/fuzzy_storage.c2
-rw-r--r--src/http_proxy.c8
-rw-r--r--src/libcryptobox/keypair.c12
-rw-r--r--src/libmime/filter.c10
-rw-r--r--src/libserver/cfg_rcl.c80
-rw-r--r--src/libserver/cfg_utils.c6
-rw-r--r--src/libserver/dynamic_cfg.c44
-rw-r--r--src/libserver/protocol.c30
-rw-r--r--src/libserver/roll_history.c20
-rw-r--r--src/libserver/symbols_cache.c16
-rw-r--r--src/libstat/backends/mmaped_file.c6
-rw-r--r--src/libstat/backends/redis_backend.c20
-rw-r--r--src/libstat/backends/sqlite3_backend.c8
-rw-r--r--src/libstat/learn_cache/redis_cache.c10
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c2
-rw-r--r--src/libstat/stat_config.c4
-rw-r--r--src/libstat/stat_process.c2
-rw-r--r--src/libstat/tokenizers/osb.c10
-rw-r--r--src/libutil/upstream.c2
-rw-r--r--src/lua/lua_classifier.c2
-rw-r--r--src/lua/lua_common.c4
-rw-r--r--src/lua/lua_config.c2
-rw-r--r--src/lua_worker.c2
-rw-r--r--src/plugins/fuzzy_check.c36
-rw-r--r--src/plugins/regexp.c20
-rw-r--r--src/plugins/surbl.c4
-rw-r--r--src/rspamadm/configdump.c16
-rw-r--r--src/rspamadm/confighelp.c6
30 files changed, 263 insertions, 263 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index ed5fb8eb3..7240d5367 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -470,16 +470,16 @@ rspamc_symbol_output (FILE *out, const ucl_object_t *obj)
gboolean first = TRUE;
rspamd_fprintf (out, "Symbol: %s ", ucl_object_key (obj));
- val = ucl_object_find_key (obj, "score");
+ val = ucl_object_lookup (obj, "score");
if (val != NULL) {
rspamd_fprintf (out, "(%.2f)", ucl_object_todouble (val));
}
- val = ucl_object_find_key (obj, "options");
+ val = ucl_object_lookup (obj, "options");
if (val != NULL && val->type == UCL_ARRAY) {
rspamd_fprintf (out, "[");
- while ((cur = ucl_iterate_object (val, &it, TRUE)) != NULL) {
+ while ((cur = ucl_object_iterate (val, &it, TRUE)) != NULL) {
if (first) {
rspamd_fprintf (out, "%s", ucl_object_tostring (cur));
first = FALSE;
@@ -514,7 +514,7 @@ rspamc_metric_output (FILE *out, const ucl_object_t *obj)
sym_ptr = g_ptr_array_new ();
rspamd_fprintf (out, "[Metric: %s]\n", ucl_object_key (obj));
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (g_ascii_strcasecmp (ucl_object_key (cur), "is_spam") == 0) {
rspamd_fprintf (out, "Spam: %s\n", ucl_object_toboolean (cur) ?
"true" : "false");
@@ -560,7 +560,7 @@ rspamc_symbols_output (FILE *out, ucl_object_t *obj)
const ucl_object_t *cur, *cmesg;
gchar *emitted;
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (g_ascii_strcasecmp (ucl_object_key (cur), "message-id") == 0) {
rspamd_fprintf (out, "Message-ID: %s\n", ucl_object_tostring (
cur));
@@ -591,7 +591,7 @@ rspamc_symbols_output (FILE *out, ucl_object_t *obj)
else if (g_ascii_strcasecmp (ucl_object_key (cur), "messages") == 0) {
if (cur->type == UCL_ARRAY) {
mit = NULL;
- while ((cmesg = ucl_iterate_object (cur, &mit, true)) != NULL) {
+ while ((cmesg = ucl_object_iterate (cur, &mit, true)) != NULL) {
rspamd_fprintf (out, "Message: %s\n",
ucl_object_tostring (cmesg));
}
@@ -610,13 +610,13 @@ rspamc_uptime_output (FILE *out, ucl_object_t *obj)
const ucl_object_t *elt;
int64_t seconds, days, hours, minutes;
- elt = ucl_object_find_key (obj, "version");
+ elt = ucl_object_lookup (obj, "version");
if (elt != NULL) {
rspamd_fprintf (out, "Rspamd version: %s\n", ucl_object_tostring (
elt));
}
- elt = ucl_object_find_key (obj, "uptime");
+ elt = ucl_object_lookup (obj, "uptime");
if (elt != NULL) {
rspamd_printf ("Uptime: ");
seconds = ucl_object_toint (elt);
@@ -661,8 +661,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2)
}
if (g_ascii_strcasecmp (args[0], "name") == 0) {
- elt1 = ucl_object_find_key (*o1, "symbol");
- elt2 = ucl_object_find_key (*o2, "symbol");
+ elt1 = ucl_object_lookup (*o1, "symbol");
+ elt2 = ucl_object_lookup (*o2, "symbol");
if (elt1 && elt2) {
c = strcmp (ucl_object_tostring (elt1),
@@ -673,8 +673,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2)
}
}
else if (g_ascii_strcasecmp (args[0], "weight") == 0) {
- elt1 = ucl_object_find_key (*o1, "weight");
- elt2 = ucl_object_find_key (*o2, "weight");
+ elt1 = ucl_object_lookup (*o1, "weight");
+ elt2 = ucl_object_lookup (*o2, "weight");
if (elt1 && elt2) {
order1 = ucl_object_todouble (elt1) * 1000.0;
@@ -682,8 +682,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2)
}
}
else if (g_ascii_strcasecmp (args[0], "frequency") == 0) {
- elt1 = ucl_object_find_key (*o1, "frequency");
- elt2 = ucl_object_find_key (*o2, "frequency");
+ elt1 = ucl_object_lookup (*o1, "frequency");
+ elt2 = ucl_object_lookup (*o2, "frequency");
if (elt1 && elt2) {
order1 = ucl_object_toint (elt1);
@@ -691,8 +691,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2)
}
}
else if (g_ascii_strcasecmp (args[0], "time") == 0) {
- elt1 = ucl_object_find_key (*o1, "time");
- elt2 = ucl_object_find_key (*o2, "time");
+ elt1 = ucl_object_lookup (*o1, "time");
+ elt2 = ucl_object_lookup (*o2, "time");
if (elt1 && elt2) {
order1 = ucl_object_todouble (elt1) * 1000000;
@@ -726,8 +726,8 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj)
}
/* Find maximum width of symbol's name */
- while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) {
- sym = ucl_object_find_key (cur, "symbol");
+ while ((cur = ucl_object_iterate (obj, &iter, true)) != NULL) {
+ sym = ucl_object_lookup (cur, "symbol");
if (sym != NULL) {
l = sym->len;
if (l > max_len) {
@@ -755,12 +755,12 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj)
iter = NULL;
i = 0;
- while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &iter, true)) != NULL) {
printf (" %s \n", dash_buf);
- sym = ucl_object_find_key (cur, "symbol");
- weight = ucl_object_find_key (cur, "weight");
- freq = ucl_object_find_key (cur, "frequency");
- tim = ucl_object_find_key (cur, "time");
+ sym = ucl_object_lookup (cur, "symbol");
+ weight = ucl_object_lookup (cur, "weight");
+ freq = ucl_object_lookup (cur, "frequency");
+ tim = ucl_object_lookup (cur, "time");
if (sym && weight && freq && tim) {
printf (fmt_buf, i,
ucl_object_tostring (sym),
@@ -776,12 +776,12 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj)
static void
rspamc_stat_actions (ucl_object_t *obj, GString *out, gint64 scanned)
{
- const ucl_object_t *actions = ucl_object_find_key (obj, "actions"), *cur;
+ const ucl_object_t *actions = ucl_object_lookup (obj, "actions"), *cur;
ucl_object_iter_t iter = NULL;
gint64 spam, ham;
if (actions && ucl_object_type (actions) == UCL_OBJECT) {
- while ((cur = ucl_iterate_object (actions, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (actions, &iter, true)) != NULL) {
gint64 cnt = ucl_object_toint (cur);
rspamd_printf_gstring (out, "Messages with action %s: %L"
", %.2f%%\n", ucl_object_key (cur), cnt,
@@ -789,8 +789,8 @@ rspamc_stat_actions (ucl_object_t *obj, GString *out, gint64 scanned)
}
}
- spam = ucl_object_toint (ucl_object_find_key (obj, "spam_count"));
- ham = ucl_object_toint (ucl_object_find_key (obj, "ham_count"));
+ spam = ucl_object_toint (ucl_object_lookup (obj, "spam_count"));
+ ham = ucl_object_toint (ucl_object_lookup (obj, "ham_count"));
rspamd_printf_gstring (out, "Messages treated as spam: %L, %.2f%%\n", spam,
((gdouble)spam / (gdouble)scanned) * 100.);
rspamd_printf_gstring (out, "Messages treated as ham: %L, %.2f%%\n", ham,
@@ -803,15 +803,15 @@ rspamc_stat_statfile (const ucl_object_t *obj, GString *out)
gint64 version, size, blocks, used_blocks, nlanguages, nusers;
const gchar *label, *symbol, *type;
- version = ucl_object_toint (ucl_object_find_key (obj, "revision"));
- size = ucl_object_toint (ucl_object_find_key (obj, "size"));
- blocks = ucl_object_toint (ucl_object_find_key (obj, "total"));
- used_blocks = ucl_object_toint (ucl_object_find_key (obj, "used"));
- label = ucl_object_tostring (ucl_object_find_key (obj, "label"));
- symbol = ucl_object_tostring (ucl_object_find_key (obj, "symbol"));
- type = ucl_object_tostring (ucl_object_find_key (obj, "type"));
- nlanguages = ucl_object_toint (ucl_object_find_key (obj, "languages"));
- nusers = ucl_object_toint (ucl_object_find_key (obj, "users"));
+ version = ucl_object_toint (ucl_object_lookup (obj, "revision"));
+ size = ucl_object_toint (ucl_object_lookup (obj, "size"));
+ blocks = ucl_object_toint (ucl_object_lookup (obj, "total"));
+ used_blocks = ucl_object_toint (ucl_object_lookup (obj, "used"));
+ label = ucl_object_tostring (ucl_object_lookup (obj, "label"));
+ symbol = ucl_object_tostring (ucl_object_lookup (obj, "symbol"));
+ type = ucl_object_tostring (ucl_object_lookup (obj, "type"));
+ nlanguages = ucl_object_toint (ucl_object_lookup (obj, "languages"));
+ nusers = ucl_object_toint (ucl_object_lookup (obj, "users"));
if (label) {
rspamd_printf_gstring (out, "Statfile: %s <%s> type: %s; ", symbol,
@@ -839,7 +839,7 @@ rspamc_stat_output (FILE *out, ucl_object_t *obj)
out_str = g_string_sized_new (BUFSIZ);
- scanned = ucl_object_toint (ucl_object_find_key (obj, "scanned"));
+ scanned = ucl_object_toint (ucl_object_lookup (obj, "scanned"));
rspamd_printf_gstring (out_str, "Messages scanned: %L\n",
scanned);
@@ -848,66 +848,66 @@ rspamc_stat_output (FILE *out, ucl_object_t *obj)
}
rspamd_printf_gstring (out_str, "Messages learned: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "learned")));
+ ucl_object_toint (ucl_object_lookup (obj, "learned")));
rspamd_printf_gstring (out_str, "Connections count: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "connections")));
+ ucl_object_toint (ucl_object_lookup (obj, "connections")));
rspamd_printf_gstring (out_str, "Control connections count: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "control_connections")));
+ ucl_object_toint (ucl_object_lookup (obj, "control_connections")));
/* Pools */
rspamd_printf_gstring (out_str, "Pools allocated: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "pools_allocated")));
+ ucl_object_toint (ucl_object_lookup (obj, "pools_allocated")));
rspamd_printf_gstring (out_str, "Pools freed: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "pools_freed")));
+ ucl_object_toint (ucl_object_lookup (obj, "pools_freed")));
rspamd_printf_gstring (out_str, "Bytes allocated: %HL\n",
- ucl_object_toint (ucl_object_find_key (obj, "bytes_allocated")));
+ ucl_object_toint (ucl_object_lookup (obj, "bytes_allocated")));
rspamd_printf_gstring (out_str, "Memory chunks allocated: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "chunks_allocated")));
+ ucl_object_toint (ucl_object_lookup (obj, "chunks_allocated")));
rspamd_printf_gstring (out_str, "Shared chunks allocated: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "shared_chunks_allocated")));
+ ucl_object_toint (ucl_object_lookup (obj, "shared_chunks_allocated")));
rspamd_printf_gstring (out_str, "Chunks freed: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "chunks_freed")));
+ ucl_object_toint (ucl_object_lookup (obj, "chunks_freed")));
rspamd_printf_gstring (out_str, "Oversized chunks: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "chunks_oversized")));
+ ucl_object_toint (ucl_object_lookup (obj, "chunks_oversized")));
/* Fuzzy */
rspamd_printf_gstring (out_str, "Fuzzy hashes stored: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "fuzzy_stored")));
+ ucl_object_toint (ucl_object_lookup (obj, "fuzzy_stored")));
rspamd_printf_gstring (out_str, "Fuzzy hashes expired: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "fuzzy_expired")));
+ ucl_object_toint (ucl_object_lookup (obj, "fuzzy_expired")));
- st = ucl_object_find_key (obj, "fuzzy_checked");
+ st = ucl_object_lookup (obj, "fuzzy_checked");
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) {
rspamd_printf_gstring (out_str, "Fuzzy hashes checked: ");
iter = NULL;
- while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) {
rspamd_printf_gstring (out_str, "%hL ", ucl_object_toint (cur));
}
rspamd_printf_gstring (out_str, "\n");
}
- st = ucl_object_find_key (obj, "fuzzy_found");
+ st = ucl_object_lookup (obj, "fuzzy_found");
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) {
rspamd_printf_gstring (out_str, "Fuzzy hashes found: ");
iter = NULL;
- while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) {
rspamd_printf_gstring (out_str, "%hL ", ucl_object_toint (cur));
}
rspamd_printf_gstring (out_str, "\n");
}
- st = ucl_object_find_key (obj, "statfiles");
+ st = ucl_object_lookup (obj, "statfiles");
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) {
iter = NULL;
- while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) {
rspamc_stat_statfile (cur, out_str);
}
}
rspamd_printf_gstring (out_str, "Total learns: %L\n",
- ucl_object_toint (ucl_object_find_key (obj, "total_learns")));
+ ucl_object_toint (ucl_object_lookup (obj, "total_learns")));
rspamd_fprintf (out, "%v", out_str);
}
@@ -997,21 +997,21 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input,
added_headers = g_string_sized_new (127);
if (result) {
- metric = ucl_object_find_key (result, "default");
+ metric = ucl_object_lookup (result, "default");
if (metric != NULL) {
- res = ucl_object_find_key (metric, "action");
+ res = ucl_object_lookup (metric, "action");
if (res) {
action = ucl_object_tostring (res);
}
- res = ucl_object_find_key (metric, "score");
+ res = ucl_object_lookup (metric, "score");
if (res) {
score = ucl_object_todouble (res);
}
- res = ucl_object_find_key (metric, "required_score");
+ res = ucl_object_lookup (metric, "required_score");
if (res) {
required_score = ucl_object_todouble (res);
}
@@ -1050,7 +1050,7 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input,
/* Short description of all symbols */
symbuf = g_string_sized_new (64);
- while ((cur = ucl_iterate_object (metric, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (metric, &it, true)) != NULL) {
if (ucl_object_type (cur) == UCL_OBJECT) {
rspamd_printf_gstring (symbuf, "%s,", ucl_object_key (cur));
diff --git a/src/controller.c b/src/controller.c
index 7d39be8d4..67f45b7c3 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1592,7 +1592,7 @@ rspamd_controller_handle_saveactions (
}
for (i = 0; i < 3; i++) {
- cur = ucl_iterate_object (obj, &it, TRUE);
+ cur = ucl_object_iterate (obj, &it, TRUE);
if (cur == NULL) {
break;
}
@@ -1705,15 +1705,15 @@ rspamd_controller_handle_savesymbols (
return 0;
}
- while ((cur = ucl_iterate_object (obj, &iter, true))) {
+ while ((cur = ucl_object_iterate (obj, &iter, true))) {
if (cur->type != UCL_OBJECT) {
msg_err_session ("json array data error");
rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
ucl_object_unref (obj);
return 0;
}
- jname = ucl_object_find_key (cur, "name");
- jvalue = ucl_object_find_key (cur, "value");
+ jname = ucl_object_lookup (cur, "name");
+ jvalue = ucl_object_lookup (cur, "value");
val = ucl_object_todouble (jvalue);
sym =
g_hash_table_lookup (metric->symbols, ucl_object_tostring (jname));
@@ -2257,23 +2257,23 @@ rspamd_controller_load_saved_stats (struct rspamd_controller_worker_ctx *ctx)
stat = ctx->srv->stat;
memcpy (&stat_copy, stat, sizeof (stat_copy));
- elt = ucl_object_find_key (obj, "scanned");
+ elt = ucl_object_lookup (obj, "scanned");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
stat_copy.messages_scanned = ucl_object_toint (elt);
}
- elt = ucl_object_find_key (obj, "learned");
+ elt = ucl_object_lookup (obj, "learned");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
stat_copy.messages_learned = ucl_object_toint (elt);
}
- elt = ucl_object_find_key (obj, "actions");
+ elt = ucl_object_lookup (obj, "actions");
if (elt != NULL) {
for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i++) {
- subelt = ucl_object_find_key (elt, rspamd_action_to_str (i));
+ subelt = ucl_object_lookup (elt, rspamd_action_to_str (i));
if (subelt && ucl_object_type (subelt) == UCL_INT) {
stat_copy.actions_stat[i] = ucl_object_toint (subelt);
@@ -2281,13 +2281,13 @@ rspamd_controller_load_saved_stats (struct rspamd_controller_worker_ctx *ctx)
}
}
- elt = ucl_object_find_key (obj, "connections_count");
+ elt = ucl_object_lookup (obj, "connections_count");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
stat_copy.connections_count = ucl_object_toint (elt);
}
- elt = ucl_object_find_key (obj, "control_connections_count");
+ elt = ucl_object_lookup (obj, "control_connections_count");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
stat_copy.control_connections_count = ucl_object_toint (elt);
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 158cdf187..844198a21 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1128,7 +1128,7 @@ fuzzy_parse_keypair (rspamd_mempool_t *pool,
msg_info_pool ("loaded keypair %*xs", 8, pk);
}
else if (ucl_object_type (obj) == UCL_ARRAY) {
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (!fuzzy_parse_keypair (pool, cur, pd, section, err)) {
return FALSE;
}
diff --git a/src/http_proxy.c b/src/http_proxy.c
index 02f676945..5cdd18c70 100644
--- a/src/http_proxy.c
+++ b/src/http_proxy.c
@@ -116,7 +116,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool,
return FALSE;
}
- elt = ucl_object_find_key (obj, "name");
+ elt = ucl_object_lookup (obj, "name");
if (elt == NULL) {
g_set_error (err, http_proxy_quark (), 100,
"upstream option must have some name definition");
@@ -127,7 +127,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool,
up = g_slice_alloc0 (sizeof (*up));
up->name = g_strdup (ucl_object_tostring (elt));
- elt = ucl_object_find_key (obj, "key");
+ elt = ucl_object_lookup (obj, "key");
if (elt != NULL) {
up->key = rspamd_pubkey_from_base32 (ucl_object_tostring (elt), 0,
RSPAMD_KEYPAIR_KEX, RSPAMD_CRYPTOBOX_MODE_25519);
@@ -140,7 +140,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool,
}
}
- elt = ucl_object_find_key (obj, "hosts");
+ elt = ucl_object_lookup (obj, "hosts");
if (elt == NULL) {
g_set_error (err, http_proxy_quark (), 100,
@@ -157,7 +157,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool,
goto err;
}
- elt = ucl_object_find_key (obj, "default");
+ elt = ucl_object_lookup (obj, "default");
if (elt && ucl_object_toboolean (elt)) {
ctx->default_upstream = up;
}
diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c
index 51b372b51..a2b842320 100644
--- a/src/libcryptobox/keypair.c
+++ b/src/libcryptobox/keypair.c
@@ -644,25 +644,25 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj)
return NULL;
}
- elt = ucl_object_find_key (obj, "keypair");
+ elt = ucl_object_lookup (obj, "keypair");
if (elt != NULL) {
obj = elt;
}
- pubkey = ucl_object_find_any_key (obj, "pubkey", "public", "public_key",
+ pubkey = ucl_object_lookup_any (obj, "pubkey", "public", "public_key",
NULL);
if (pubkey == NULL || ucl_object_type (pubkey) != UCL_STRING) {
return NULL;
}
- privkey = ucl_object_find_any_key (obj, "privkey", "private", "private_key",
+ privkey = ucl_object_lookup_any (obj, "privkey", "private", "private_key",
"secret", "secret_key", NULL);
if (privkey == NULL || ucl_object_type (privkey) != UCL_STRING) {
return NULL;
}
/* Optional fields */
- elt = ucl_object_find_key (obj, "type");
+ elt = ucl_object_lookup (obj, "type");
if (elt && ucl_object_type (elt) == UCL_STRING) {
str = ucl_object_tostring (elt);
@@ -675,7 +675,7 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj)
/* TODO: handle errors */
}
- elt = ucl_object_find_key (obj, "algorithm");
+ elt = ucl_object_lookup (obj, "algorithm");
if (elt && ucl_object_type (elt) == UCL_STRING) {
str = ucl_object_tostring (elt);
@@ -688,7 +688,7 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj)
/* TODO: handle errors */
}
- elt = ucl_object_find_key (obj, "encoding");
+ elt = ucl_object_lookup (obj, "encoding");
if (elt && ucl_object_type (elt) == UCL_STRING) {
str = ucl_object_tostring (elt);
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 79ad37838..303ef2e0f 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -101,11 +101,11 @@ insert_metric_result (struct rspamd_task *task,
}
if (task->settings) {
- mobj = ucl_object_find_key (task->settings, metric->name);
+ mobj = ucl_object_lookup (task->settings, metric->name);
if (mobj) {
gdouble corr;
- sobj = ucl_object_find_key (mobj, symbol);
+ sobj = ucl_object_lookup (mobj, symbol);
if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) {
msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f",
symbol, w, corr);
@@ -349,10 +349,10 @@ get_specific_action_score (struct rspamd_task *task,
double score;
if (metric) {
- act = ucl_object_find_key (metric, "actions");
+ act = ucl_object_lookup (metric, "actions");
if (act) {
act_name = rspamd_action_to_str (action->action);
- sact = ucl_object_find_key (act, act_name);
+ sact = ucl_object_lookup (act, act_name);
if (sact != NULL && ucl_object_todouble_safe (sact, &score)) {
msg_debug_task ("found override score %.2f for action %s in settings",
score, act_name);
@@ -374,7 +374,7 @@ rspamd_check_action_metric (struct rspamd_task *task,
int i;
if (task->settings) {
- ms = ucl_object_find_key (task->settings, metric->name);
+ ms = ucl_object_lookup (task->settings, metric->name);
}
for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index cae9317d6..7a6ea429d 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -92,11 +92,11 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *facility, *log_type, *log_level;
struct rspamd_config *cfg = ud;
- val = ucl_object_find_key (obj, "type");
+ val = ucl_object_lookup (obj, "type");
if (val != NULL && ucl_object_tostring_safe (val, &log_type)) {
if (g_ascii_strcasecmp (log_type, "file") == 0) {
/* Need to get filename */
- val = ucl_object_find_key (obj, "filename");
+ val = ucl_object_lookup (obj, "filename");
if (val == NULL || val->type != UCL_STRING) {
g_set_error (err,
CFG_RCL_ERROR,
@@ -113,7 +113,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
#ifdef HAVE_SYSLOG_H
cfg->log_facility = LOG_DAEMON;
cfg->log_type = RSPAMD_LOG_SYSLOG;
- val = ucl_object_find_key (obj, "facility");
+ val = ucl_object_lookup (obj, "facility");
if (val != NULL && ucl_object_tostring_safe (val, &facility)) {
if (g_ascii_strcasecmp (facility, "LOG_AUTH") == 0 ||
g_ascii_strcasecmp (facility, "auth") == 0 ) {
@@ -198,7 +198,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
/* Handle log level */
- val = ucl_object_find_key (obj, "level");
+ val = ucl_object_lookup (obj, "level");
if (val != NULL && ucl_object_tostring_safe (val, &log_level)) {
if (g_ascii_strcasecmp (log_level, "error") == 0) {
cfg->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
@@ -237,7 +237,7 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
HASH_FIND_STR (section->subsections, "dns", dns_section);
- dns = ucl_object_find_key (obj, "dns");
+ dns = ucl_object_lookup (obj, "dns");
if (dns_section != NULL && dns != NULL) {
if (!rspamd_rcl_section_parse_defaults (dns_section, cfg->cfg_pool, dns,
cfg, err)) {
@@ -247,7 +247,7 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
HASH_FIND_STR (section->subsections, "upstream", upstream_section);
- upstream = ucl_object_find_key (obj, "upstream");
+ upstream = ucl_object_lookup (obj, "upstream");
if (upstream_section != NULL && upstream != NULL) {
if (!rspamd_rcl_section_parse_defaults (upstream_section, cfg->cfg_pool,
upstream, cfg, err)) {
@@ -294,7 +294,7 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
sd->gr = gr;
/* Handle symbols */
- val = ucl_object_find_key (obj, "symbol");
+ val = ucl_object_lookup (obj, "symbol");
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
HASH_FIND_STR (section->subsections, "symbol", subsection);
g_assert (subsection != NULL);
@@ -358,13 +358,13 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
msg_warn_config ("redefining symbol '%s' in metric '%s'", key, metric->name);
}
- if ((elt = ucl_object_find_key (obj, "one_shot")) != NULL) {
+ if ((elt = ucl_object_lookup (obj, "one_shot")) != NULL) {
if (ucl_object_toboolean (elt)) {
sym_def->flags |= RSPAMD_SYMBOL_FLAG_ONESHOT;
}
}
- if ((elt = ucl_object_find_key (obj, "ignore")) != NULL) {
+ if ((elt = ucl_object_lookup (obj, "ignore")) != NULL) {
if (ucl_object_toboolean (elt)) {
sym_def->flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
}
@@ -375,7 +375,7 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
return FALSE;
}
- if (ucl_object_find_any_key (obj, "score", "weight", NULL) != NULL) {
+ if (ucl_object_lookup_any (obj, "score", "weight", NULL) != NULL) {
*sym_def->weight_ptr = sym_def->score;
}
@@ -394,7 +394,7 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const ucl_object_t *cur;
ucl_object_iter_t it = NULL;
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (!rspamd_action_from_str (ucl_object_key (cur), &action_value) ||
!ucl_object_todouble_safe (cur, &action_score)) {
g_set_error (err,
@@ -444,7 +444,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
/* Handle actions */
- val = ucl_object_find_key (obj, "actions");
+ val = ucl_object_lookup (obj, "actions");
if (val != NULL) {
if (val->type != UCL_OBJECT) {
g_set_error (err, CFG_RCL_ERROR, EINVAL,
@@ -463,7 +463,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
/* No more legacy mode */
/* Handle grouped symbols */
- val = ucl_object_find_key (obj, "group");
+ val = ucl_object_lookup (obj, "group");
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
HASH_FIND_STR (section->subsections, "group", subsection);
g_assert (subsection != NULL);
@@ -480,7 +480,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
/* Handle symbols */
- val = ucl_object_find_key (obj, "symbol");
+ val = ucl_object_lookup (obj, "symbol");
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
HASH_FIND_STR (section->subsections, "symbol", subsection);
g_assert (subsection != NULL);
@@ -497,12 +497,12 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
/* Handle ignored symbols */
- val = ucl_object_find_key (obj, "ignore");
+ val = ucl_object_lookup (obj, "ignore");
if (val != NULL && ucl_object_type (val) == UCL_ARRAY) {
LL_FOREACH (val, cur) {
it = NULL;
- while ((elt = ucl_iterate_object (cur, &it, true)) != NULL) {
+ while ((elt = ucl_object_iterate (cur, &it, true)) != NULL) {
if (ucl_object_type (elt) == UCL_STRING) {
sym_def = g_hash_table_lookup (metric->symbols,
ucl_object_tostring (elt));
@@ -543,7 +543,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
g_assert (key != NULL);
worker_type = key;
- val = ucl_object_find_any_key (obj, "module", "load", NULL);
+ val = ucl_object_lookup_any (obj, "module", "load", NULL);
if (val != NULL && ucl_object_tostring_safe (val, &lib_path)) {
@@ -608,7 +608,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
return TRUE;
}
- val = ucl_object_find_any_key (obj, "bind_socket", "listen", "bind", NULL);
+ val = ucl_object_lookup_any (obj, "bind_socket", "listen", "bind", NULL);
/* This name is more logical */
if (val != NULL) {
it = ucl_object_iterate_new (val);
@@ -641,7 +641,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
if (wparser != NULL && obj->type == UCL_OBJECT) {
it = NULL;
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
srch.name = ucl_object_key (cur);
srch.ptr = wrk->ctx; /* XXX: is it valid? */
whandler = g_hash_table_lookup (wparser->parsers, &srch);
@@ -952,7 +952,7 @@ rspamd_rcl_modules_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *data;
if (obj->type == UCL_OBJECT) {
- val = ucl_object_find_key (obj, "path");
+ val = ucl_object_lookup (obj, "path");
LL_FOREACH (val, cur)
{
@@ -1032,7 +1032,7 @@ rspamd_rcl_statfile_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
st->opts = (ucl_object_t *)obj;
st->clcf = ccf;
- val = ucl_object_find_key (obj, "spam");
+ val = ucl_object_lookup (obj, "spam");
if (val == NULL) {
msg_info_config (
"statfile %s has no explicit 'spam' setting, trying to guess by symbol",
@@ -1100,7 +1100,7 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool,
ccf->name = ccf->classifier;
}
- while ((val = ucl_iterate_object (obj, &it, true)) != NULL && res) {
+ while ((val = ucl_object_iterate (obj, &it, true)) != NULL && res) {
st_key = ucl_object_key (val);
if (st_key != NULL) {
if (g_ascii_strcasecmp (st_key, "statfile") == 0) {
@@ -1122,13 +1122,13 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool,
tkcf->name = ucl_object_tostring (val);
}
else if (ucl_object_type (val) == UCL_OBJECT) {
- cur = ucl_object_find_key (val, "name");
+ cur = ucl_object_lookup (val, "name");
if (cur != NULL) {
tkcf->name = ucl_object_tostring (cur);
tkcf->opts = val;
}
else {
- cur = ucl_object_find_key (val, "type");
+ cur = ucl_object_lookup (val, "type");
if (cur != NULL) {
tkcf->name = ucl_object_tostring (cur);
tkcf->opts = val;
@@ -1183,7 +1183,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
new = FALSE;
}
- val = ucl_object_find_key (obj, "expression");
+ val = ucl_object_lookup (obj, "expression");
if (val == NULL || !ucl_object_tostring_safe (val, &composite_expression)) {
g_set_error (err,
CFG_RCL_ERROR,
@@ -1219,11 +1219,11 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1);
}
- val = ucl_object_find_key (obj, "score");
+ val = ucl_object_lookup (obj, "score");
if (val != NULL && ucl_object_todouble_safe (val, &score)) {
/* Also set score in the metric */
- val = ucl_object_find_key (obj, "group");
+ val = ucl_object_lookup (obj, "group");
if (val != NULL) {
group = ucl_object_tostring (val);
}
@@ -1231,7 +1231,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
group = "composite";
}
- val = ucl_object_find_key (obj, "metric");
+ val = ucl_object_lookup (obj, "metric");
if (val != NULL) {
metric = ucl_object_tostring (val);
}
@@ -1239,7 +1239,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
metric = DEFAULT_METRIC;
}
- val = ucl_object_find_key (obj, "description");
+ val = ucl_object_lookup (obj, "description");
if (val != NULL) {
description = ucl_object_tostring (val);
}
@@ -2057,7 +2057,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec,
it = NULL;
if (sec->key_attr != NULL) {
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (ucl_object_type (cur) != UCL_OBJECT) {
is_nested = FALSE;
break;
@@ -2072,7 +2072,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec,
/* Just reiterate on all subobjects */
it = NULL;
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (!sec->handler (pool, cur, ucl_object_key (cur), ptr, sec, err)) {
return FALSE;
}
@@ -2083,7 +2083,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec,
else {
if (sec->key_attr != NULL) {
/* First of all search for required attribute and use it as a key */
- cur = ucl_object_find_key (obj, sec->key_attr);
+ cur = ucl_object_lookup (obj, sec->key_attr);
if (cur == NULL) {
if (sec->default_key == NULL) {
@@ -2156,7 +2156,7 @@ rspamd_rcl_parse (struct rspamd_rcl_section *top,
}
}
else {
- found = ucl_object_find_key (obj, cur->name);
+ found = ucl_object_lookup (obj, cur->name);
if (found == NULL) {
if (cur->required) {
g_set_error (err, CFG_RCL_ERROR, ENOENT,
@@ -2217,7 +2217,7 @@ rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
HASH_ITER (hh, section->default_parser, cur, tmp)
{
- found = ucl_object_find_key (obj, cur->key);
+ found = ucl_object_lookup (obj, cur->key);
if (found != NULL) {
cur->pd.user_struct = ptr;
@@ -2817,7 +2817,7 @@ rspamd_rcl_register_worker_option (struct rspamd_config *cfg,
g_hash_table_insert (nparser->parsers, &nhandler->key, nhandler);
- doc_workers = ucl_object_find_key (cfg->doc_strings, "workers");
+ doc_workers = ucl_object_lookup (cfg->doc_strings, "workers");
if (doc_workers == NULL) {
doc_obj = ucl_object_typed_new (UCL_OBJECT);
@@ -2825,7 +2825,7 @@ rspamd_rcl_register_worker_option (struct rspamd_config *cfg,
doc_workers = doc_obj;
}
- doc_target = ucl_object_find_key (doc_workers, g_quark_to_string (type));
+ doc_target = ucl_object_lookup (doc_workers, g_quark_to_string (type));
if (doc_target == NULL) {
doc_obj = ucl_object_typed_new (UCL_OBJECT);
@@ -2952,11 +2952,11 @@ rspamd_rcl_doc_obj_from_handler (ucl_object_t *doc_obj,
gboolean has_example = FALSE, has_type = FALSE;
const gchar *type = NULL;
- if (ucl_object_find_key (doc_obj, "example") != NULL) {
+ if (ucl_object_lookup (doc_obj, "example") != NULL) {
has_example = TRUE;
}
- if (ucl_object_find_key (doc_obj, "type") != NULL) {
+ if (ucl_object_lookup (doc_obj, "type") != NULL) {
has_type = TRUE;
}
@@ -3145,7 +3145,7 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg,
required);
}
else {
- found = ucl_lookup_path (cfg->doc_strings, doc_path);
+ found = ucl_object_lookup_path (cfg->doc_strings, doc_path);
if (found != NULL) {
return rspamd_rcl_add_doc_obj ((ucl_object_t *) found,
@@ -3169,7 +3169,7 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg,
return NULL;
}
- found = ucl_object_find_key (cur, *comp);
+ found = ucl_object_lookup (cur, *comp);
if (found == NULL) {
obj = ucl_object_typed_new (UCL_OBJECT);
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 1b924859f..3e1e0d84e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1144,7 +1144,7 @@ rspamd_ucl_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
ucl_parser_free (parser);
it = NULL;
- while ((cur = ucl_iterate_object (obj, &it, true))) {
+ while ((cur = ucl_object_iterate (obj, &it, true))) {
ucl_object_replace_key (cbdata->cfg->rcl_obj, (ucl_object_t *)cur,
cur->key, cur->keylen, false);
}
@@ -1427,7 +1427,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
}
}
- conf = ucl_object_find_key (cfg->rcl_obj, module_name);
+ conf = ucl_object_lookup (cfg->rcl_obj, module_name);
if (conf == NULL) {
msg_info_config ("%s module %s is enabled but has not been configured",
@@ -1439,7 +1439,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
}
}
else {
- enabled = ucl_object_find_key (conf, "enabled");
+ enabled = ucl_object_lookup (conf, "enabled");
if (enabled && ucl_object_type (enabled) == UCL_BOOLEAN) {
if (!ucl_object_toboolean (enabled)) {
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index 92447a037..9c8ffe9a7 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -40,13 +40,13 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
struct metric_action *cur_action;
struct rspamd_symbol_def *s;
- while ((cur_elt = ucl_iterate_object (top, &it, true))) {
+ while ((cur_elt = ucl_object_iterate (top, &it, true))) {
if (ucl_object_type (cur_elt) != UCL_OBJECT) {
msg_err ("loaded json array element is not an object");
continue;
}
- cur_nm = ucl_object_find_key (cur_elt, "metric");
+ cur_nm = ucl_object_lookup (cur_elt, "metric");
if (!cur_nm || ucl_object_type (cur_nm) != UCL_STRING) {
msg_err (
"loaded json metric object element has no 'metric' attribute");
@@ -59,18 +59,18 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
continue;
}
- cur_nm = ucl_object_find_key (cur_elt, "symbols");
+ cur_nm = ucl_object_lookup (cur_elt, "symbols");
/* Parse symbols */
if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) {
ucl_object_iter_t nit = NULL;
- while ((it_val = ucl_iterate_object (cur_nm, &nit, true))) {
- if (ucl_object_find_key (it_val, "name") &&
- ucl_object_find_key (it_val, "value")) {
+ while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
+ if (ucl_object_lookup (it_val, "name") &&
+ ucl_object_lookup (it_val, "value")) {
const ucl_object_t *n =
- ucl_object_find_key (it_val, "name");
+ ucl_object_lookup (it_val, "name");
const ucl_object_t *v =
- ucl_object_find_key (it_val, "value");
+ ucl_object_lookup (it_val, "value");
if((s = g_hash_table_lookup (real_metric->symbols,
ucl_object_tostring (n))) != NULL) {
@@ -90,25 +90,25 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
ucl_object_insert_key ((ucl_object_t *)cur_elt, arr, "symbols",
sizeof ("symbols") - 1, false);
}
- cur_nm = ucl_object_find_key (cur_elt, "actions");
+ cur_nm = ucl_object_lookup (cur_elt, "actions");
/* Parse actions */
if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) {
ucl_object_iter_t nit = NULL;
- while ((it_val = ucl_iterate_object (cur_nm, &nit, true))) {
- if (ucl_object_find_key (it_val, "name") &&
- ucl_object_find_key (it_val, "value")) {
+ while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
+ if (ucl_object_lookup (it_val, "name") &&
+ ucl_object_lookup (it_val, "value")) {
if (!rspamd_action_from_str (ucl_object_tostring (
- ucl_object_find_key (it_val, "name")), &test_act)) {
+ ucl_object_lookup (it_val, "name")), &test_act)) {
msg_err ("unknown action: %s",
- ucl_object_tostring (ucl_object_find_key (it_val,
+ ucl_object_tostring (ucl_object_lookup (it_val,
"name")));
continue;
}
cur_action = &real_metric->actions[test_act];
cur_action->action = test_act;
cur_action->score =
- ucl_object_todouble (ucl_object_find_key (it_val,
+ ucl_object_todouble (ucl_object_lookup (it_val,
"value"));
}
else {
@@ -340,12 +340,12 @@ dynamic_metric_find_elt (const ucl_object_t *arr, const gchar *name)
ucl_object_iter_t it = NULL;
const ucl_object_t *cur, *n;
- while ((cur = ucl_iterate_object (arr, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) {
if (cur->type == UCL_OBJECT) {
- n = ucl_object_find_key (cur, "name");
+ n = ucl_object_lookup (cur, "name");
if (n && n->type == UCL_STRING &&
strcmp (name, ucl_object_tostring (n)) == 0) {
- return (ucl_object_t *)ucl_object_find_key (cur, "value");
+ return (ucl_object_t *)ucl_object_lookup (cur, "value");
}
}
}
@@ -359,9 +359,9 @@ dynamic_metric_find_metric (const ucl_object_t *arr, const gchar *metric)
ucl_object_iter_t it = NULL;
const ucl_object_t *cur, *n;
- while ((cur = ucl_iterate_object (arr, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) {
if (cur->type == UCL_OBJECT) {
- n = ucl_object_find_key (cur, "metric");
+ n = ucl_object_lookup (cur, "metric");
if (n && n->type == UCL_STRING &&
strcmp (metric, ucl_object_tostring (n)) == 0) {
return (ucl_object_t *)cur;
@@ -415,7 +415,7 @@ add_dynamic_symbol (struct rspamd_config *cfg,
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
}
- syms = (ucl_object_t *)ucl_object_find_key (metric, "symbols");
+ syms = (ucl_object_t *)ucl_object_lookup (metric, "symbols");
if (syms != NULL) {
ucl_object_t *sym;
@@ -462,7 +462,7 @@ add_dynamic_action (struct rspamd_config *cfg,
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
}
- acts = (ucl_object_t *)ucl_object_find_key (metric, "actions");
+ acts = (ucl_object_t *)ucl_object_lookup (metric, "actions");
if (acts != NULL) {
ucl_object_t *act;
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 1b4a05392..fd9ce5703 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -862,44 +862,44 @@ rspamd_ucl_torspamc_output (struct rspamd_task *task,
*required_score, *is_spam, *elt, *cur;
ucl_object_iter_t iter = NULL;
- metric = ucl_object_find_key (top, DEFAULT_METRIC);
+ metric = ucl_object_lookup (top, DEFAULT_METRIC);
if (metric != NULL) {
- score = ucl_object_find_key (metric, "score");
- required_score = ucl_object_find_key (metric, "required_score");
- is_spam = ucl_object_find_key (metric, "is_spam");
+ score = ucl_object_lookup (metric, "score");
+ required_score = ucl_object_lookup (metric, "required_score");
+ is_spam = ucl_object_lookup (metric, "is_spam");
rspamd_printf_fstring (out,
"Metric: default; %s; %.2f / %.2f / 0.0\r\n",
ucl_object_toboolean (is_spam) ? "True" : "False",
ucl_object_todouble (score),
ucl_object_todouble (required_score));
- elt = ucl_object_find_key (metric, "action");
+ elt = ucl_object_lookup (metric, "action");
if (elt != NULL) {
rspamd_printf_fstring (out, "Action: %s\r\n",
ucl_object_tostring (elt));
}
iter = NULL;
- while ((elt = ucl_iterate_object (metric, &iter, true)) != NULL) {
+ while ((elt = ucl_object_iterate (metric, &iter, true)) != NULL) {
if (elt->type == UCL_OBJECT) {
const ucl_object_t *sym_score;
- sym_score = ucl_object_find_key (elt, "score");
+ sym_score = ucl_object_lookup (elt, "score");
rspamd_printf_fstring (out, "Symbol: %s(%.2f)\r\n",
ucl_object_key (elt),
ucl_object_todouble (sym_score));
}
}
- elt = ucl_object_find_key (metric, "subject");
+ elt = ucl_object_lookup (metric, "subject");
if (elt != NULL) {
rspamd_printf_fstring (out, "Subject: %s\r\n",
ucl_object_tostring (elt));
}
}
- elt = ucl_object_find_key (top, "messages");
+ elt = ucl_object_lookup (top, "messages");
if (elt != NULL) {
iter = NULL;
- while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate (elt, &iter, true)) != NULL) {
if (cur->type == UCL_STRING) {
rspamd_printf_fstring (out, "Message: %s\r\n",
ucl_object_tostring (cur));
@@ -920,18 +920,18 @@ rspamd_ucl_tospamc_output (struct rspamd_task *task,
ucl_object_iter_t iter = NULL;
rspamd_fstring_t *f;
- metric = ucl_object_find_key (top, DEFAULT_METRIC);
+ metric = ucl_object_lookup (top, DEFAULT_METRIC);
if (metric != NULL) {
- score = ucl_object_find_key (metric, "score");
- required_score = ucl_object_find_key (metric, "required_score");
- is_spam = ucl_object_find_key (metric, "is_spam");
+ score = ucl_object_lookup (metric, "score");
+ required_score = ucl_object_lookup (metric, "required_score");
+ is_spam = ucl_object_lookup (metric, "is_spam");
rspamd_printf_fstring (out,
"Spam: %s ; %.2f / %.2f\r\n\r\n",
ucl_object_toboolean (is_spam) ? "True" : "False",
ucl_object_todouble (score),
ucl_object_todouble (required_score));
- while ((elt = ucl_iterate_object (metric, &iter, true)) != NULL) {
+ while ((elt = ucl_object_iterate (metric, &iter, true)) != NULL) {
if (elt->type == UCL_OBJECT) {
rspamd_printf_fstring (out, "%s,",
ucl_object_key (elt));
diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c
index 89185825a..ca577317d 100644
--- a/src/libserver/roll_history.c
+++ b/src/libserver/roll_history.c
@@ -239,65 +239,65 @@ rspamd_roll_history_load (struct roll_history *history, const gchar *filename)
row = &history->rows[i];
memset (row, 0, sizeof (*row));
- elt = ucl_object_find_key (cur, "time");
+ elt = ucl_object_lookup (cur, "time");
if (elt && ucl_object_type (elt) == UCL_FLOAT) {
double_to_tv (ucl_object_todouble (elt), &row->tv);
}
- elt = ucl_object_find_key (cur, "id");
+ elt = ucl_object_lookup (cur, "id");
if (elt && ucl_object_type (elt) == UCL_STRING) {
rspamd_strlcpy (row->message_id, ucl_object_tostring (elt),
sizeof (row->message_id));
}
- elt = ucl_object_find_key (cur, "symbols");
+ elt = ucl_object_lookup (cur, "symbols");
if (elt && ucl_object_type (elt) == UCL_STRING) {
rspamd_strlcpy (row->symbols, ucl_object_tostring (elt),
sizeof (row->symbols));
}
- elt = ucl_object_find_key (cur, "user");
+ elt = ucl_object_lookup (cur, "user");
if (elt && ucl_object_type (elt) == UCL_STRING) {
rspamd_strlcpy (row->user, ucl_object_tostring (elt),
sizeof (row->user));
}
- elt = ucl_object_find_key (cur, "from");
+ elt = ucl_object_lookup (cur, "from");
if (elt && ucl_object_type (elt) == UCL_STRING) {
rspamd_strlcpy (row->from_addr, ucl_object_tostring (elt),
sizeof (row->from_addr));
}
- elt = ucl_object_find_key (cur, "len");
+ elt = ucl_object_lookup (cur, "len");
if (elt && ucl_object_type (elt) == UCL_INT) {
row->len = ucl_object_toint (elt);
}
- elt = ucl_object_find_key (cur, "scan_time");
+ elt = ucl_object_lookup (cur, "scan_time");
if (elt && ucl_object_type (elt) == UCL_FLOAT) {
row->scan_time = ucl_object_todouble (elt);
}
- elt = ucl_object_find_key (cur, "score");
+ elt = ucl_object_lookup (cur, "score");
if (elt && ucl_object_type (elt) == UCL_FLOAT) {
row->score = ucl_object_todouble (elt);
}
- elt = ucl_object_find_key (cur, "required_score");
+ elt = ucl_object_lookup (cur, "required_score");
if (elt && ucl_object_type (elt) == UCL_FLOAT) {
row->required_score = ucl_object_todouble (elt);
}
- elt = ucl_object_find_key (cur, "action");
+ elt = ucl_object_lookup (cur, "action");
if (elt && ucl_object_type (elt) == UCL_INT) {
row->action = ucl_object_toint (elt);
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index b5facfce8..74176f695 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -391,7 +391,7 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name)
* metric
*/
#if 0
- elt = ucl_object_find_key (cur, "weight");
+ elt = ucl_object_lookup (cur, "weight");
if (elt) {
w = ucl_object_todouble (elt);
@@ -400,17 +400,17 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name)
}
}
#endif
- elt = ucl_object_find_key (cur, "time");
+ elt = ucl_object_lookup (cur, "time");
if (elt) {
item->avg_time = ucl_object_todouble (elt);
}
- elt = ucl_object_find_key (cur, "count");
+ elt = ucl_object_lookup (cur, "count");
if (elt) {
item->avg_counter = ucl_object_toint (elt);
}
- elt = ucl_object_find_key (cur, "frequency");
+ elt = ucl_object_lookup (cur, "frequency");
if (elt) {
item->frequency = ucl_object_toint (elt);
}
@@ -914,11 +914,11 @@ check_metric_settings (struct rspamd_task *task, struct metric *metric,
return FALSE;
}
- mobj = ucl_object_find_key (task->settings, metric->name);
+ mobj = ucl_object_lookup (task->settings, metric->name);
if (mobj != NULL) {
- act = ucl_object_find_key (mobj, "actions");
+ act = ucl_object_lookup (mobj, "actions");
if (act != NULL) {
- reject = ucl_object_find_key (act,
+ reject = ucl_object_lookup (act,
rspamd_action_to_str (METRIC_ACTION_REJECT));
if (reject != NULL && ucl_object_todouble_safe (reject, &val)) {
*score = val;
@@ -1198,7 +1198,7 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
if (task->settings) {
const ucl_object_t *wl;
- wl = ucl_object_find_key (task->settings, "whitelist");
+ wl = ucl_object_lookup (task->settings, "whitelist");
if (wl != NULL) {
msg_info_task ("<%s> is whitelisted", task->message_id);
task->flags |= RSPAMD_TASK_FLAG_SKIP;
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index d5b466a9a..eba730cab 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -799,10 +799,10 @@ rspamd_mmaped_file_init (struct rspamd_stat_ctx *ctx,
const gchar *filename;
gsize size;
- filenameo = ucl_object_find_key (stf->opts, "filename");
+ filenameo = ucl_object_lookup (stf->opts, "filename");
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
- filenameo = ucl_object_find_key (stf->opts, "path");
+ filenameo = ucl_object_lookup (stf->opts, "path");
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
msg_err_config ("statfile %s has no filename defined", stf->symbol);
@@ -812,7 +812,7 @@ rspamd_mmaped_file_init (struct rspamd_stat_ctx *ctx,
filename = ucl_object_tostring (filenameo);
- sizeo = ucl_object_find_key (stf->opts, "size");
+ sizeo = ucl_object_lookup (stf->opts, "size");
if (sizeo == NULL || ucl_object_type (sizeo) != UCL_INT) {
msg_err_config ("statfile %s has no size defined", stf->symbol);
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 61644d004..a862ace6d 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -465,7 +465,7 @@ rspamd_redis_stat_learns (redisAsyncContext *c, gpointer r, gpointer priv)
rspamd_strtoul (reply->str, reply->len, &num);
}
- obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "revision");
+ obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "revision");
if (obj) {
obj->value.iv += num;
}
@@ -500,17 +500,17 @@ rspamd_redis_stat_key (redisAsyncContext *c, gpointer r, gpointer priv)
num = 0;
}
- obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "used");
+ obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "used");
if (obj) {
obj->value.iv += num;
}
- obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "total");
+ obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "total");
if (obj) {
obj->value.iv += num;
}
- obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "size");
+ obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "size");
if (obj) {
/* Size of key + size of int64_t */
obj->value.iv += num * (sizeof (G_STRINGIFY (G_MAXINT64)) +
@@ -856,11 +856,11 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
backend = g_slice_alloc0 (sizeof (*backend));
- elt = ucl_object_find_any_key (stf->opts, "read_servers", "servers", NULL);
+ elt = ucl_object_lookup_any (stf->opts, "read_servers", "servers", NULL);
if (elt == NULL) {
if (st->classifier->cfg->opts) {
- elt = ucl_object_find_any_key (st->classifier->cfg->opts,
+ elt = ucl_object_lookup_any (st->classifier->cfg->opts,
"read_servers", "servers", NULL);
}
@@ -880,7 +880,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
return NULL;
}
- elt = ucl_object_find_key (stf->opts, "write_servers");
+ elt = ucl_object_lookup (stf->opts, "write_servers");
if (elt == NULL) {
/* Use read servers as write ones */
g_assert (relt != NULL);
@@ -903,7 +903,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
}
}
- elt = ucl_object_find_key (stf->opts, "prefix");
+ elt = ucl_object_lookup (stf->opts, "prefix");
if (elt == NULL || ucl_object_type (elt) != UCL_STRING) {
/* Default non-users statistics */
backend->redis_object = REDIS_DEFAULT_OBJECT;
@@ -911,7 +911,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
/*
* Make redis backend compatible with sqlite3 backend in users settings
*/
- users_enabled = ucl_object_find_any_key (stf->clcf->opts, "per_user",
+ users_enabled = ucl_object_lookup_any (stf->clcf->opts, "per_user",
"users_enabled", NULL);
if (users_enabled != NULL) {
@@ -954,7 +954,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
backend->redis_object = ucl_object_tostring (elt);
}
- elt = ucl_object_find_key (stf->opts, "timeout");
+ elt = ucl_object_lookup (stf->opts, "timeout");
if (elt) {
backend->timeout = ucl_object_todouble (elt);
}
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index 0ea172125..9d582e063 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -523,9 +523,9 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx,
struct rspamd_stat_sqlite3_db *bk;
GError *err = NULL;
- filenameo = ucl_object_find_key (stf->opts, "filename");
+ filenameo = ucl_object_lookup (stf->opts, "filename");
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
- filenameo = ucl_object_find_key (stf->opts, "path");
+ filenameo = ucl_object_lookup (stf->opts, "path");
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
msg_err_config ("statfile %s has no filename defined", stf->symbol);
return NULL;
@@ -543,7 +543,7 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx,
bk->L = cfg->lua_state;
- users_enabled = ucl_object_find_any_key (clf->opts, "per_user",
+ users_enabled = ucl_object_lookup_any (clf->opts, "per_user",
"users_enabled", NULL);
if (users_enabled != NULL) {
if (ucl_object_type (users_enabled) == UCL_BOOLEAN) {
@@ -576,7 +576,7 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx,
bk->enable_users = FALSE;
}
- lang_enabled = ucl_object_find_any_key (clf->opts,
+ lang_enabled = ucl_object_lookup_any (clf->opts,
"per_language", "languages_enabled", NULL);
if (lang_enabled != NULL) {
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 47bfd89a6..6dc9d5336 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -185,11 +185,11 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx,
cache_ctx = g_slice_alloc0 (sizeof (*cache_ctx));
- elt = ucl_object_find_any_key (stf->opts, "read_servers", "servers", NULL);
+ elt = ucl_object_lookup_any (stf->opts, "read_servers", "servers", NULL);
if (elt == NULL) {
if (st->classifier->cfg->opts) {
- elt = ucl_object_find_any_key (st->classifier->cfg->opts,
+ elt = ucl_object_lookup_any (st->classifier->cfg->opts,
"read_servers", "servers", NULL);
}
@@ -209,7 +209,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx,
return NULL;
}
- elt = ucl_object_find_key (stf->opts, "write_servers");
+ elt = ucl_object_lookup (stf->opts, "write_servers");
if (elt == NULL) {
/* Use read servers as write ones */
g_assert (relt != NULL);
@@ -232,7 +232,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx,
}
}
- elt = ucl_object_find_key (stf->opts, "key");
+ elt = ucl_object_lookup (stf->opts, "key");
if (elt == NULL || ucl_object_type (elt) != UCL_STRING) {
cache_ctx->redis_object = DEFAULT_REDIS_KEY;
}
@@ -240,7 +240,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx,
cache_ctx->redis_object = ucl_object_tostring (elt);
}
- elt = ucl_object_find_key (stf->opts, "timeout");
+ elt = ucl_object_lookup (stf->opts, "timeout");
if (elt) {
cache_ctx->timeout = ucl_object_todouble (elt);
}
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c
index 41731fa10..61335ab34 100644
--- a/src/libstat/learn_cache/sqlite3_cache.c
+++ b/src/libstat/learn_cache/sqlite3_cache.c
@@ -125,7 +125,7 @@ rspamd_stat_cache_sqlite3_init (struct rspamd_stat_ctx *ctx,
GError *err = NULL;
if (cf) {
- elt = ucl_object_find_any_key (cf, "path", "file", NULL);
+ elt = ucl_object_lookup_any (cf, "path", "file", NULL);
if (elt != NULL) {
path = ucl_object_tostring (elt);
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 96af1eb53..6e383baf1 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -152,11 +152,11 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
cache_name = NULL;
if (clf->opts) {
- cache_obj = ucl_object_find_key (clf->opts, "cache");
+ cache_obj = ucl_object_lookup (clf->opts, "cache");
cache_name_obj = NULL;
if (cache_obj) {
- cache_name_obj = ucl_object_find_any_key (cache_obj,
+ cache_name_obj = ucl_object_lookup_any (cache_obj,
"name", "type", NULL);
}
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index b50a36894..6b1b16aed 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -702,7 +702,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task)
ret = FALSE;
if (cl->cfg->opts) {
- obj = ucl_object_find_key (cl->cfg->opts, "autolearn");
+ obj = ucl_object_lookup (cl->cfg->opts, "autolearn");
if (ucl_object_type (obj) == UCL_BOOLEAN) {
if (ucl_object_toboolean (obj)) {
diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c
index bfeac55cc..906c1de25 100644
--- a/src/libstat/tokenizers/osb.c
+++ b/src/libstat/tokenizers/osb.c
@@ -97,12 +97,12 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool,
def = rspamd_tokenizer_osb_default_config ();
memcpy (cf, def, sizeof (*cf));
- elt = ucl_object_find_key (obj, "hash");
+ elt = ucl_object_lookup (obj, "hash");
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
if (g_ascii_strncasecmp (ucl_object_tostring (elt), "xxh", 3)
== 0) {
cf->ht = RSPAMD_OSB_HASH_XXHASH;
- elt = ucl_object_find_key (obj, "seed");
+ elt = ucl_object_lookup (obj, "seed");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
cf->seed = ucl_object_toint (elt);
}
@@ -110,7 +110,7 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool,
else if (g_ascii_strncasecmp (ucl_object_tostring (elt), "sip", 3)
== 0) {
cf->ht = RSPAMD_OSB_HASH_SIPHASH;
- elt = ucl_object_find_key (obj, "key");
+ elt = ucl_object_lookup (obj, "key");
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
key = rspamd_decode_base32 (ucl_object_tostring (elt),
@@ -131,13 +131,13 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool,
}
}
else {
- elt = ucl_object_find_key (obj, "compat");
+ elt = ucl_object_lookup (obj, "compat");
if (elt != NULL && ucl_object_toboolean (elt)) {
cf->ht = RSPAMD_OSB_HASH_COMPAT;
}
}
- elt = ucl_object_find_key (obj, "window");
+ elt = ucl_object_lookup (obj, "window");
if (elt != NULL && ucl_object_type (elt) == UCL_INT) {
cf->window_size = ucl_object_toint (elt);
if (cf->window_size > DEFAULT_FEATURE_WINDOW_SIZE * 4) {
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index b1af43b50..574cf0667 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -643,7 +643,7 @@ rspamd_upstreams_from_ucl (struct upstream_list *ups,
ucl_object_iter_t it = NULL;
if (ucl_object_type (in) == UCL_ARRAY) {
- while ((cur = ucl_iterate_object (in, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (in, &it, true)) != NULL) {
if (rspamd_upstreams_from_ucl (ups, cur, def_port, data)) {
ret = TRUE;
}
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index d8add5e4d..f777ba8aa 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -364,7 +364,7 @@ lua_statfile_get_param (lua_State *L)
param = luaL_checkstring (L, 2);
if (st != NULL && param != NULL) {
- value = ucl_object_find_key (st->opts, param);
+ value = ucl_object_lookup (st->opts, param);
if (value != NULL) {
lua_pushstring (L, ucl_object_tostring_forced (value));
return 1;
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index eb3b7de3f..960d3457d 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -173,9 +173,9 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg)
return;
}
- opts = ucl_object_find_key (cfg->rcl_obj, "options");
+ opts = ucl_object_lookup (cfg->rcl_obj, "options");
if (opts != NULL) {
- opts = ucl_object_find_key (opts, "lua_path");
+ opts = ucl_object_lookup (opts, "lua_path");
if (opts != NULL && ucl_object_type (opts) == UCL_STRING) {
additional_path = ucl_object_tostring (opts);
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 9cf18fa22..4421bf179 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -900,7 +900,7 @@ lua_config_get_key (lua_State *L)
name = luaL_checklstring(L, 2, &namelen);
if (name && cfg) {
- val = ucl_object_find_keyl(cfg->rcl_obj, name, namelen);
+ val = ucl_object_lookup_len(cfg->rcl_obj, name, namelen);
if (val != NULL) {
ucl_object_push_lua (L, val, val->type != UCL_ARRAY);
}
diff --git a/src/lua_worker.c b/src/lua_worker.c
index 5f8c96fa9..8f02e12b2 100644
--- a/src/lua_worker.c
+++ b/src/lua_worker.c
@@ -192,7 +192,7 @@ lua_worker_get_option (lua_State *L)
lua_pushnil (L);
}
else {
- val = ucl_object_find_key (ctx->opts, name);
+ val = ucl_object_lookup (ctx->opts, name);
if (val == NULL) {
lua_pushnil (L);
}
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 788601f1e..d51a1637a 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -170,7 +170,7 @@ parse_flags (struct fuzzy_rule *rule,
"string mappings are deprecated and no longer supported, use new style configuration");
}
else if (val->type == UCL_OBJECT) {
- elt = ucl_object_find_key (val, "symbol");
+ elt = ucl_object_lookup (val, "symbol");
if (elt == NULL || !ucl_object_tostring_safe (elt, &sym)) {
sym = ucl_object_key (val);
}
@@ -179,11 +179,11 @@ parse_flags (struct fuzzy_rule *rule,
rspamd_mempool_alloc (fuzzy_module_ctx->fuzzy_pool,
sizeof (struct fuzzy_mapping));
map->symbol = sym;
- elt = ucl_object_find_key (val, "flag");
+ elt = ucl_object_lookup (val, "flag");
if (elt != NULL) {
map->fuzzy_flag = ucl_obj_toint (elt);
- elt = ucl_object_find_key (val, "max_score");
+ elt = ucl_object_lookup (val, "max_score");
if (elt != NULL) {
map->weight = ucl_obj_todouble (elt);
@@ -361,9 +361,9 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
fuzzy_module_ctx->fuzzy_pool);
rule->learn_condition_cb = -1;
- if ((value = ucl_object_find_key (obj, "mime_types")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "mime_types")) != NULL) {
it = NULL;
- while ((cur = ucl_iterate_object (value, &it, value->type == UCL_ARRAY))
+ while ((cur = ucl_object_iterate (value, &it, value->type == UCL_ARRAY))
!= NULL) {
rule->mime_types = g_list_concat (rule->mime_types,
parse_mime_types (ucl_obj_tostring (cur)));
@@ -375,9 +375,9 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
(rspamd_mempool_destruct_t)g_list_free, rule->mime_types);
}
- if ((value = ucl_object_find_key (obj, "headers")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "headers")) != NULL) {
it = NULL;
- while ((cur = ucl_iterate_object (value, &it, value->type == UCL_ARRAY))
+ while ((cur = ucl_object_iterate (value, &it, value->type == UCL_ARRAY))
!= NULL) {
rule->fuzzy_headers = g_list_concat (rule->fuzzy_headers,
parse_fuzzy_headers (ucl_obj_tostring (cur)));
@@ -394,20 +394,20 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
}
- if ((value = ucl_object_find_key (obj, "max_score")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "max_score")) != NULL) {
rule->max_score = ucl_obj_todouble (value);
}
- if ((value = ucl_object_find_key (obj, "symbol")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "symbol")) != NULL) {
rule->symbol = ucl_obj_tostring (value);
}
- if ((value = ucl_object_find_key (obj, "read_only")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "read_only")) != NULL) {
rule->read_only = ucl_obj_toboolean (value);
}
- if ((value = ucl_object_find_key (obj, "skip_unknown")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "skip_unknown")) != NULL) {
rule->skip_unknown = ucl_obj_toboolean (value);
}
- if ((value = ucl_object_find_key (obj, "servers")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "servers")) != NULL) {
rule->servers = rspamd_upstreams_create (cfg->ups_ctx);
rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
@@ -418,14 +418,14 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
return -1;
}
}
- if ((value = ucl_object_find_key (obj, "fuzzy_map")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "fuzzy_map")) != NULL) {
it = NULL;
- while ((cur = ucl_iterate_object (value, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (value, &it, true)) != NULL) {
parse_flags (rule, cfg, cur, cb_id);
}
}
- if ((value = ucl_object_find_key (obj, "encryption_key")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "encryption_key")) != NULL) {
/* Create key from user's input */
k = ucl_object_tostring (value);
@@ -441,7 +441,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
RSPAMD_CRYPTOBOX_MODE_25519);
}
- if ((value = ucl_object_find_key (obj, "learn_condition")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "learn_condition")) != NULL) {
lua_script = ucl_object_tostring (value);
if (lua_script) {
@@ -466,7 +466,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
}
}
- if ((value = ucl_object_find_key (obj, "fuzzy_key")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "fuzzy_key")) != NULL) {
/* Create key from user's input */
k = ucl_object_tostring (value);
}
@@ -481,7 +481,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id
rspamd_cryptobox_hash (rule->hash_key->str, k, strlen (k), NULL, 0);
rule->hash_key->len = rspamd_cryptobox_HASHKEYBYTES;
- if ((value = ucl_object_find_key (obj, "fuzzy_shingles_key")) != NULL) {
+ if ((value = ucl_object_lookup (obj, "fuzzy_shingles_key")) != NULL) {
k = ucl_object_tostring (value);
}
if (k == NULL) {
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index fbe612fbc..6458e1577 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -129,7 +129,7 @@ regexp_module_config (struct rspamd_config *cfg)
return TRUE;
}
- sec = ucl_object_find_key (cfg->rcl_obj, "regexp");
+ sec = ucl_object_lookup (cfg->rcl_obj, "regexp");
if (sec == NULL) {
msg_err_config ("regexp module enabled, but no rules are defined");
return TRUE;
@@ -137,7 +137,7 @@ regexp_module_config (struct rspamd_config *cfg)
regexp_module_ctx->max_size = 0;
- while ((value = ucl_iterate_object (sec, &it, true)) != NULL) {
+ while ((value = ucl_object_iterate (sec, &it, true)) != NULL) {
if (g_ascii_strncasecmp (ucl_object_key (value), "max_size",
sizeof ("max_size") - 1) == 0) {
regexp_module_ctx->max_size = ucl_obj_toint (value);
@@ -187,12 +187,12 @@ regexp_module_config (struct rspamd_config *cfg)
gboolean one_shot = FALSE, is_lua = FALSE, valid_expression = TRUE;
/* We have some lua table, extract its arguments */
- elt = ucl_object_find_key (value, "callback");
+ elt = ucl_object_lookup (value, "callback");
if (elt == NULL || elt->type != UCL_USERDATA) {
/* Try plain regexp expression */
- elt = ucl_object_find_any_key (value, "regexp", "re", NULL);
+ elt = ucl_object_lookup_any (value, "regexp", "re", NULL);
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool,
@@ -232,7 +232,7 @@ regexp_module_config (struct rspamd_config *cfg)
cur_item,
SYMBOL_TYPE_NORMAL, -1);
- elt = ucl_object_find_key (value, "condition");
+ elt = ucl_object_lookup (value, "condition");
if (elt != NULL && ucl_object_type (elt) == UCL_USERDATA) {
struct ucl_lua_funcdata *conddata;
@@ -242,31 +242,31 @@ regexp_module_config (struct rspamd_config *cfg)
conddata->L, conddata->idx);
}
- elt = ucl_object_find_key (value, "metric");
+ elt = ucl_object_lookup (value, "metric");
if (elt) {
metric = ucl_object_tostring (elt);
}
- elt = ucl_object_find_key (value, "description");
+ elt = ucl_object_lookup (value, "description");
if (elt) {
description = ucl_object_tostring (elt);
}
- elt = ucl_object_find_key (value, "group");
+ elt = ucl_object_lookup (value, "group");
if (elt) {
group = ucl_object_tostring (elt);
}
- elt = ucl_object_find_key (value, "score");
+ elt = ucl_object_lookup (value, "score");
if (elt) {
score = ucl_object_todouble (elt);
}
- elt = ucl_object_find_key (value, "one_shot");
+ elt = ucl_object_lookup (value, "one_shot");
if (elt) {
one_shot = ucl_object_toboolean (elt);
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index b49ed8f3c..b87e79f0d 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -671,7 +671,7 @@ surbl_module_config (struct rspamd_config *cfg)
if (cur != NULL && cur->type == UCL_OBJECT) {
it = NULL;
while ((cur_bit =
- ucl_iterate_object (cur, &it, true)) != NULL) {
+ ucl_object_iterate (cur, &it, true)) != NULL) {
if (ucl_object_key (cur_bit) != NULL && cur_bit->type ==
UCL_INT) {
gchar *p;
@@ -708,7 +708,7 @@ surbl_module_config (struct rspamd_config *cfg)
new_suffix->ips);
while ((cur_bit =
- ucl_iterate_object (cur, &it, true)) != NULL) {
+ ucl_object_iterate (cur, &it, true)) != NULL) {
if (ucl_object_key (cur_bit) != NULL) {
gchar *p;
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index ca89b5325..c246509e3 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -109,7 +109,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
}
/* We create comments as a list of parts */
- elt = ucl_object_find_key (doc_obj, "data");
+ elt = ucl_object_lookup (doc_obj, "data");
if (elt) {
rspamd_printf_fstring (&comment, " * %s", ucl_object_tostring (elt));
cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0);
@@ -117,7 +117,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
DL_APPEND (nobj, cur_comment);
}
- elt = ucl_object_find_key (doc_obj, "type");
+ elt = ucl_object_lookup (doc_obj, "type");
if (elt) {
rspamd_printf_fstring (&comment, " * Type: %s", ucl_object_tostring (elt));
cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0);
@@ -125,7 +125,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
DL_APPEND (nobj, cur_comment);
}
- elt = ucl_object_find_key (doc_obj, "required");
+ elt = ucl_object_lookup (doc_obj, "required");
if (elt) {
rspamd_printf_fstring (&comment, " * Required: %B",
ucl_object_toboolean (elt));
@@ -161,13 +161,13 @@ rspamadm_gen_comments (const ucl_object_t *obj, const ucl_object_t *doc_obj,
}
if (ucl_object_type (obj) == UCL_OBJECT) {
- while ((cur_obj = ucl_iterate_object (obj, &it, true))) {
- cur_doc = ucl_object_find_keyl (doc_obj, cur_obj->key,
+ while ((cur_obj = ucl_object_iterate (obj, &it, true))) {
+ cur_doc = ucl_object_lookup_len (doc_obj, cur_obj->key,
cur_obj->keylen);
if (cur_doc != NULL) {
LL_FOREACH (cur_obj, cur_elt) {
- if (ucl_object_find_keyl (comments, (const char *)&cur_elt,
+ if (ucl_object_lookup_len (comments, (const char *)&cur_elt,
sizeof (void *)) == NULL) {
rspamadm_gen_comments (cur_elt, cur_doc, comments);
}
@@ -281,8 +281,8 @@ rspamadm_configdump (gint argc, gchar **argv)
}
else {
for (i = 1; i < argc; i ++) {
- obj = ucl_lookup_path (cfg->rcl_obj, argv[i]);
- doc_obj = ucl_lookup_path (cfg->doc_strings, argv[i]);
+ obj = ucl_object_lookup_path (cfg->rcl_obj, argv[i]);
+ doc_obj = ucl_object_lookup_path (cfg->doc_strings, argv[i]);
if (!obj) {
rspamd_printf ("Section %s NOT FOUND\n", argv[i]);
diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c
index 3e395a295..010ebb834 100644
--- a/src/rspamadm/confighelp.c
+++ b/src/rspamadm/confighelp.c
@@ -126,7 +126,7 @@ rspamadm_confighelp_search_word_step (const ucl_object_t *obj,
const ucl_object_t *cur, *elt;
const gchar *dot_pos;
- while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
+ while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) {
if (cur->keylen > 0) {
rspamd_printf_gstring (path, ".%*s", (int) cur->keylen, cur->key);
@@ -141,7 +141,7 @@ rspamadm_confighelp_search_word_step (const ucl_object_t *obj,
}
if (ucl_object_type (cur) == UCL_OBJECT) {
- elt = ucl_object_find_key (cur, "data");
+ elt = ucl_object_lookup (cur, "data");
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
if (rspamd_substring_search_caseless (elt->value.sv,
@@ -252,7 +252,7 @@ rspamadm_confighelp (gint argc, gchar **argv)
}
else {
doc_obj = ucl_object_typed_new (UCL_OBJECT);
- elt = ucl_lookup_path (cfg->doc_strings, argv[i]);
+ elt = ucl_object_lookup_path (cfg->doc_strings, argv[i]);
if (elt) {
ucl_object_insert_key (doc_obj, ucl_object_ref (elt),