From: Vsevolod Stakhov Date: Wed, 17 Dec 2014 12:11:55 +0000 (+0000) Subject: Remove direct ucl access. X-Git-Tag: 0.8.0~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5bcf9f0af263b25ab6c5b128e767cc8a2a39312a;p=rspamd.git Remove direct ucl access. --- diff --git a/src/client/rspamc.c b/src/client/rspamc.c index 393441925..2a3191f27 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -411,26 +411,28 @@ add_options (GHashTable *opts) static void rspamc_symbol_output (const ucl_object_t *obj) { - const ucl_object_t *cur, *it; + const ucl_object_t *val, *cur; + ucl_object_iter_t it = NULL; + gboolean first = TRUE; rspamd_fprintf (stdout, "Symbol: %s ", ucl_object_key (obj)); - cur = ucl_object_find_key (obj, "score"); + val = ucl_object_find_key (obj, "score"); - if (cur != NULL) { - rspamd_fprintf (stdout, "(%.2f)", ucl_object_todouble (cur)); + if (val != NULL) { + rspamd_fprintf (stdout, "(%.2f)", ucl_object_todouble (val)); } - cur = ucl_object_find_key (obj, "options"); - if (cur != NULL && cur->type == UCL_ARRAY) { - it = cur->value.av; + val = ucl_object_find_key (obj, "options"); + if (val != NULL && val->type == UCL_ARRAY) { rspamd_fprintf (stdout, "["); - while (it) { - if (it->next) { - rspamd_fprintf (stdout, "%s, ", ucl_object_tostring (it)); + + while ((cur = ucl_iterate_object (val, &it, TRUE)) != NULL) { + if (first) { + rspamd_fprintf (stdout, "%s", ucl_object_tostring (cur)); + first = FALSE; } else { - rspamd_fprintf (stdout, "%s", ucl_object_tostring (it)); + rspamd_fprintf (stdout, ", %s", ucl_object_tostring (cur)); } - it = it->next; } rspamd_fprintf (stdout, "]"); } diff --git a/src/controller.c b/src/controller.c index fe9d6bc29..33422f782 100644 --- a/src/controller.c +++ b/src/controller.c @@ -935,12 +935,14 @@ rspamd_controller_handle_saveactions ( struct rspamd_controller_session *session = conn_ent->ud; struct ucl_parser *parser; struct metric *metric; - ucl_object_t *obj, *cur; + ucl_object_t *obj; + const ucl_object_t *cur; struct rspamd_controller_worker_ctx *ctx; const gchar *error; gdouble score; gint i, added = 0; enum rspamd_metric_action act; + ucl_object_iter_t it = NULL; ctx = session->ctx; @@ -993,8 +995,11 @@ rspamd_controller_handle_saveactions ( return 0; } - cur = obj->value.av; - for (i = 0; i < 3 && cur != NULL; i++, cur = cur->next) { + for (i = 0; i < 3; i++) { + cur = ucl_iterate_object (obj, &it, TRUE); + if (cur == NULL) { + break; + } switch (i) { case 0: act = METRIC_ACTION_REJECT; diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 0c2937c34..b3feda154 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -517,7 +517,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud) elt = ucl_object_frombool (url->is_phished); ucl_object_insert_key (obj, elt, "phished", 0, false); } - DL_APPEND (cb->top->value.av, obj); + ucl_array_append (cb->top, obj); if (cb->task->cfg->log_urls) { msg_info ("<%s> URL: %s - %s: %s", @@ -554,7 +554,7 @@ emails_protocol_cb (gpointer key, gpointer value, gpointer ud) ucl_object_t *obj; obj = ucl_object_fromlstring (url->user, url->userlen + url->hostlen + 1); - DL_APPEND (cb->top->value.av, obj); + ucl_array_append (cb->top, obj); return FALSE; } @@ -624,7 +624,7 @@ rspamd_str_list_ucl (GList *str_list) cur = str_list; while (cur) { obj = ucl_object_fromstring (cur->data); - DL_APPEND (top->value.av, obj); + ucl_array_append (top, obj); cur = g_list_next (cur); } diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index f4dc12f4a..607cd2a31 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -312,10 +312,9 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj) fuzzy_module_ctx->fuzzy_pool); if ((value = ucl_object_find_key (obj, "mime_types")) != NULL) { - if (value->type == UCL_ARRAY) { - value = value->value.av; - } - LL_FOREACH (value, cur) { + it = NULL; + while ((cur = ucl_iterate_object (value, &it, obj->type == UCL_ARRAY)) + != NULL) { rule->mime_types = g_list_concat (rule->mime_types, parse_mime_types (ucl_obj_tostring (cur))); } @@ -347,6 +346,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj) rspamd_upstreams_from_ucl (rule->servers, value, DEFAULT_PORT, NULL); } if ((value = ucl_object_find_key (obj, "fuzzy_map")) != NULL) { + it = NULL; while ((cur = ucl_iterate_object (value, &it, true)) != NULL) { parse_flags (rule, cfg, cur); }