]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Save comments from configuration files
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Feb 2016 13:28:26 +0000 (13:28 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Feb 2016 14:57:16 +0000 (14:57 +0000)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c

index 8fb0075bcfd07392b0e3e980158609ce6a0201aa..373daf744ced61bd01efbb3024d4651c72eee3ba 100644 (file)
@@ -282,6 +282,7 @@ struct rspamd_config {
        GList *workers;                                 /**< linked list of all workers params                                  */
        GHashTable *wrk_parsers;                        /**< hash for worker config parsers, indexed by worker quarks */
        ucl_object_t *rcl_obj;                          /**< rcl object                                                                                 */
+       ucl_object_t *config_comments;                  /**< comments saved from the config                                             */
        ucl_object_t *doc_strings;                      /**< documentation strings for config options                   */
        GHashTable * metrics;                           /**< hash of metrics indexed by metric name                             */
        GList * metrics_list;                           /**< linked list of metrics                                                             */
index 7a6ea429ddbd8fce37387252f0a41cfd80e05368..7b6d1180a9d99c8d1f623dd9ed7cec411141030e 100644 (file)
@@ -2908,7 +2908,7 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
        rspamd_strlcpy (cfg->cfg_pool->tag.uid, cfg->checksum,
                        MIN (sizeof (cfg->cfg_pool->tag.uid), strlen (cfg->checksum)));
 
-       parser = ucl_parser_new (0);
+       parser = ucl_parser_new (UCL_PARSER_SAVE_COMMENTS);
        rspamd_ucl_add_conf_variables (parser, vars);
        rspamd_ucl_add_conf_macros (parser, cfg);
 
@@ -2921,6 +2921,7 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
 
        munmap (data, st.st_size);
        cfg->rcl_obj = ucl_parser_get_object (parser);
+       cfg->config_comments = ucl_object_ref (ucl_parser_get_comments (parser));
        ucl_parser_free (parser);
 
        top = rspamd_rcl_config_init (cfg);
index 3e1e0d84ed606a4bfe19b0b55c7a0b0ab87a75ca..a857571c48f6cc3c10e8ba68e90ebb851373d608 100644 (file)
@@ -171,6 +171,7 @@ rspamd_config_free (struct rspamd_config *cfg)
 
        rspamd_map_remove_all (cfg);
        ucl_object_unref (cfg->rcl_obj);
+       ucl_object_unref (cfg->config_comments);
        ucl_object_unref (cfg->doc_strings);
        g_hash_table_remove_all (cfg->metrics);
        g_hash_table_unref (cfg->metrics);