]> source.dussan.org Git - rspamd.git/commitdiff
Remove direct ucl access.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Dec 2014 12:11:55 +0000 (12:11 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Dec 2014 12:11:55 +0000 (12:11 +0000)
src/client/rspamc.c
src/controller.c
src/libserver/protocol.c
src/plugins/fuzzy_check.c

index 39344192535f7a2459b0ec05f64aa4879d295010..2a3191f27bb8da64a5ef999ec60662c3d6fa0a24 100644 (file)
@@ -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, "]");
        }
index fe9d6bc2995593afcad473a1f42a66d7185ba830..33422f78243ae8b11985d17f3f1f6b5d7cd45d48 100644 (file)
@@ -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;
index 0c2937c34e1c4f357ca843857fc3f745656f4e03..b3feda154632f45d8674cc3f99b3333b24458363 100644 (file)
@@ -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);
        }
 
index f4dc12f4a33b753c4da4eeff2d1964297d260d93..607cd2a315c5af923301c5a1ed7627ab718b93a3 100644 (file)
@@ -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);
                }