aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_file.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-08 15:22:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-08 15:22:05 +0100
commitc271eb36656a4ff88a9c8c1d59934949260275a3 (patch)
tree3dd586e38b5b37cfebc7c12b6ff6f434904167c7 /src/libserver/cfg_file.h
parentb266445f47dec06392a7e058f499325fa3c052b9 (diff)
downloadrspamd-c271eb36656a4ff88a9c8c1d59934949260275a3.tar.gz
rspamd-c271eb36656a4ff88a9c8c1d59934949260275a3.zip
[Rework] Add C++ guards to all headers
Diffstat (limited to 'src/libserver/cfg_file.h')
-rw-r--r--src/libserver/cfg_file.h189
1 files changed, 101 insertions, 88 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 5f70ccda8..de00ab128 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -25,7 +25,7 @@
#include "ucl.h"
#include "regexp.h"
#include "libserver/re_cache.h"
-#include "ref.h"
+#include "libutil/ref.h"
#include "libutil/radix.h"
#include "monitored.h"
#include "redis_pool.h"
@@ -36,6 +36,10 @@
/* Default metric name */
#define DEFAULT_METRIC "default"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct expression;
struct tokenizer;
struct rspamd_stat_classifier;
@@ -149,13 +153,13 @@ struct rspamd_statfile_config {
gchar *label; /**< label of this statfile */
ucl_object_t *opts; /**< other options */
gboolean is_spam; /**< spam flag */
- struct rspamd_classifier_config *clcf; /**< parent pointer of classifier configuration */
- gpointer data; /**< opaque data */
+ struct rspamd_classifier_config *clcf; /**< parent pointer of classifier configuration */
+ gpointer data; /**< opaque data */
};
struct rspamd_tokenizer_config {
const ucl_object_t *opts; /**< other options */
- const gchar *name; /**< name of tokenizer */
+ const gchar *name; /**< name of tokenizer */
};
@@ -344,7 +348,7 @@ struct rspamd_config {
gdouble grow_factor; /**< grow factor for metric */
GHashTable *symbols; /**< weights of symbols in metric */
const gchar *subject; /**< subject rewrite string */
- GHashTable * groups; /**< groups of symbols */
+ GHashTable *groups; /**< groups of symbols */
struct rspamd_action *actions; /**< all actions of the metric */
gboolean raw_mode; /**< work in raw mode instead of utf one */
@@ -399,17 +403,17 @@ struct rspamd_config {
ucl_object_t *config_comments; /**< comments saved from the config */
ucl_object_t *doc_strings; /**< documentation strings for config options */
GPtrArray *c_modules; /**< list of C modules */
- GHashTable * composite_symbols; /**< hash of composite symbols indexed by its name */
+ GHashTable *composite_symbols; /**< hash of composite symbols indexed by its name */
GList *classifiers; /**< list of all classifiers defined */
GList *statfiles; /**< list of all statfiles in config file order */
GHashTable *classifiers_symbols; /**< hashtable indexed by symbol name of classifiers */
- GHashTable * cfg_params; /**< all cfg params indexed by its name in this structure */
+ GHashTable *cfg_params; /**< all cfg params indexed by its name in this structure */
gchar *dynamic_conf; /**< path to dynamic configuration */
ucl_object_t *current_dynamic_conf; /**< currently loaded dynamic configuration */
- GHashTable * domain_settings; /**< settings per-domains */
- GHashTable * user_settings; /**< settings per-user */
- gchar * domain_settings_str; /**< string representation of settings */
- gchar * user_settings_str;
+ GHashTable *domain_settings; /**< settings per-domains */
+ GHashTable *user_settings; /**< settings per-user */
+ gchar *domain_settings_str; /**< string representation of settings */
+ gchar *user_settings_str;
gint clock_res; /**< resolution of clock used */
GList *maps; /**< maps active */
@@ -423,16 +427,16 @@ struct rspamd_config {
struct rspamd_symcache *cache; /**< symbols cache object */
gchar *cache_filename; /**< filename of cache file */
gdouble cache_reload_time; /**< how often cache reload should be performed */
- gchar * checksum; /**< real checksum of config file */
- gchar * dump_checksum; /**< dump checksum of config file */
+ gchar *checksum; /**< real checksum of config file */
+ gchar *dump_checksum; /**< dump checksum of config file */
gpointer lua_state; /**< pointer to lua state */
gpointer lua_thread_pool; /**< pointer to lua thread (coroutine) pool */
- gchar * rrd_file; /**< rrd file to store statistics */
- gchar * history_file; /**< file to save rolling history */
- gchar * tld_file; /**< file to load effective tld list from */
- gchar * hs_cache_dir; /**< directory to save hyperscan databases */
- gchar * magic_file; /**< file to initialize libmagic */
+ gchar *rrd_file; /**< rrd file to store statistics */
+ gchar *history_file; /**< file to save rolling history */
+ gchar *tld_file; /**< file to load effective tld list from */
+ gchar *hs_cache_dir; /**< directory to save hyperscan databases */
+ gchar *magic_file; /**< file to initialize libmagic */
gdouble dns_timeout; /**< timeout in milliseconds for waiting for dns reply */
guint32 dns_retransmits; /**< maximum retransmits count */
@@ -443,49 +447,49 @@ struct rspamd_config {
guint32 dns_max_requests; /**< limit of DNS requests per task */
gboolean enable_dnssec; /**< enable dnssec stub resolver */
- guint upstream_max_errors; /**< upstream max errors before shutting off */
- gdouble upstream_error_time; /**< rate of upstream errors */
- gdouble upstream_revive_time; /**< revive timeout for upstreams */
- struct upstream_ctx *ups_ctx; /**< upstream context */
- struct rspamd_dns_resolver *dns_resolver; /**< dns resolver if loaded */
+ guint upstream_max_errors; /**< upstream max errors before shutting off */
+ gdouble upstream_error_time; /**< rate of upstream errors */
+ gdouble upstream_revive_time; /**< revive timeout for upstreams */
+ struct upstream_ctx *ups_ctx; /**< upstream context */
+ struct rspamd_dns_resolver *dns_resolver; /**< dns resolver if loaded */
- guint min_word_len; /**< minimum length of the word to be considered */
- guint max_word_len; /**< maximum length of the word to be considered */
- guint words_decay; /**< limit for words for starting adaptive ignoring */
- guint history_rows; /**< number of history rows stored */
+ guint min_word_len; /**< minimum length of the word to be considered */
+ guint max_word_len; /**< maximum length of the word to be considered */
+ guint words_decay; /**< limit for words for starting adaptive ignoring */
+ guint history_rows; /**< number of history rows stored */
guint max_sessions_cache; /**< maximum number of sessions cache elts */
- guint lua_gc_step; /**< lua gc step */
- guint lua_gc_pause; /**< lua gc pause */
- guint full_gc_iters; /**< iterations between full gc cycle */
+ guint lua_gc_step; /**< lua gc step */
+ guint lua_gc_pause; /**< lua gc pause */
+ guint full_gc_iters; /**< iterations between full gc cycle */
- GList *classify_headers; /**< list of headers using for statistics */
- struct module_s **compiled_modules; /**< list of compiled C modules */
- struct worker_s **compiled_workers; /**< list of compiled C modules */struct rspamd_log_format *log_format; /**< parsed log format */
- gchar *log_format_str; /**< raw log format string */
+ GList *classify_headers; /**< list of headers using for statistics */
+ struct module_s **compiled_modules; /**< list of compiled C modules */
+ struct worker_s **compiled_workers; /**< list of compiled C modules */struct rspamd_log_format *log_format; /**< parsed log format */
+ gchar *log_format_str; /**< raw log format string */
- struct rspamd_external_libs_ctx *libs_ctx; /**< context for external libraries */
- struct rspamd_monitored_ctx *monitored_ctx; /**< context for monitored resources */
- struct rspamd_redis_pool *redis_pool; /**< redis connectiosn pool */
+ struct rspamd_external_libs_ctx *libs_ctx; /**< context for external libraries */
+ struct rspamd_monitored_ctx *monitored_ctx; /**< context for monitored resources */
+ struct rspamd_redis_pool *redis_pool; /**< redis connectiosn pool */
- struct rspamd_re_cache *re_cache; /**< static regexp cache */
+ struct rspamd_re_cache *re_cache; /**< static regexp cache */
- GHashTable *trusted_keys; /**< list of trusted public keys */
+ GHashTable *trusted_keys; /**< list of trusted public keys */
- struct rspamd_config_cfg_lua_script *on_load_scripts; /**< list of scripts executed on workers load */
- struct rspamd_config_cfg_lua_script *post_init_scripts; /**< list of scripts executed on config being fully loaded */
+ struct rspamd_config_cfg_lua_script *on_load_scripts; /**< list of scripts executed on workers load */
+ struct rspamd_config_cfg_lua_script *post_init_scripts; /**< list of scripts executed on config being fully loaded */
struct rspamd_config_cfg_lua_script *on_term_scripts; /**< list of callbacks called on worker's termination */
- struct rspamd_config_cfg_lua_script *config_unload_scripts; /**< list of scripts executed on config unload */
+ struct rspamd_config_cfg_lua_script *config_unload_scripts; /**< list of scripts executed on config unload */
- gchar *ssl_ca_path; /**< path to CA certs */
- gchar *ssl_ciphers; /**< set of preferred ciphers */
- gchar *zstd_input_dictionary; /**< path to zstd input dictionary */
- gchar *zstd_output_dictionary; /**< path to zstd output dictionary */
- ucl_object_t *neighbours; /**< other servers in the cluster */
+ gchar *ssl_ca_path; /**< path to CA certs */
+ gchar *ssl_ciphers; /**< set of preferred ciphers */
+ gchar *zstd_input_dictionary; /**< path to zstd input dictionary */
+ gchar *zstd_output_dictionary; /**< path to zstd output dictionary */
+ ucl_object_t *neighbours; /**< other servers in the cluster */
- struct rspamd_config_settings_elt *setting_ids; /**< preprocessed settings ids */
- struct rspamd_lang_detector *lang_det; /**< language detector */
+ struct rspamd_config_settings_elt *setting_ids; /**< preprocessed settings ids */
+ struct rspamd_lang_detector *lang_det; /**< language detector */
- ref_entry_t ref; /**< reference counter */
+ ref_entry_t ref; /**< reference counter */
};
@@ -497,7 +501,7 @@ struct rspamd_config {
* @return 1 if line was successfully parsed and 0 in case of error
*/
gboolean rspamd_parse_bind_line (struct rspamd_config *cfg,
- struct rspamd_worker_conf *cf, const gchar *str);
+ struct rspamd_worker_conf *cf, const gchar *str);
enum rspamd_config_init_flags {
@@ -505,6 +509,7 @@ enum rspamd_config_init_flags {
RSPAMD_CONFIG_INIT_SKIP_LUA = (1u << 0u),
RSPAMD_CONFIG_INIT_WIPE_LUA_MEM = (1u << 1u),
};
+
/**
* Init default values
* @param cfg config file
@@ -524,9 +529,9 @@ void rspamd_config_free (struct rspamd_config *cfg);
* @param opt_name name of option to get
* @return module value or NULL if option does not defined
*/
-const ucl_object_t * rspamd_config_get_module_opt (struct rspamd_config *cfg,
- const gchar *module_name,
- const gchar *opt_name);
+const ucl_object_t *rspamd_config_get_module_opt (struct rspamd_config *cfg,
+ const gchar *module_name,
+ const gchar *opt_name);
/**
@@ -547,18 +552,18 @@ enum rspamd_post_load_options {
};
#define RSPAMD_CONFIG_LOAD_ALL (RSPAMD_CONFIG_INIT_URL| \
- RSPAMD_CONFIG_INIT_LIBS| \
- RSPAMD_CONFIG_INIT_SYMCACHE| \
- RSPAMD_CONFIG_INIT_VALIDATE| \
- RSPAMD_CONFIG_INIT_PRELOAD_MAPS| \
- RSPAMD_CONFIG_INIT_POST_LOAD_LUA)
+ RSPAMD_CONFIG_INIT_LIBS| \
+ RSPAMD_CONFIG_INIT_SYMCACHE| \
+ RSPAMD_CONFIG_INIT_VALIDATE| \
+ RSPAMD_CONFIG_INIT_PRELOAD_MAPS| \
+ RSPAMD_CONFIG_INIT_POST_LOAD_LUA)
/**
* Do post load actions for config
* @param cfg config file
*/
gboolean rspamd_config_post_load (struct rspamd_config *cfg,
- enum rspamd_post_load_options opts);
+ enum rspamd_post_load_options opts);
/**
* Calculate checksum for config file
@@ -576,20 +581,22 @@ void rspamd_config_unescape_quotes (gchar *line);
/*
* Convert comma separated string to a list of strings
*/
-GList * rspamd_config_parse_comma_list (rspamd_mempool_t *pool,
- const gchar *line);
+GList *rspamd_config_parse_comma_list (rspamd_mempool_t *pool,
+ const gchar *line);
/*
* Return a new classifier_config structure, setting default and non-conflicting attributes
*/
-struct rspamd_classifier_config * rspamd_config_new_classifier (
- struct rspamd_config *cfg,
- struct rspamd_classifier_config *c);
+struct rspamd_classifier_config *rspamd_config_new_classifier (
+ struct rspamd_config *cfg,
+ struct rspamd_classifier_config *c);
+
/*
* Return a new worker_conf structure, setting default and non-conflicting attributes
*/
-struct rspamd_worker_conf * rspamd_config_new_worker (struct rspamd_config *cfg,
- struct rspamd_worker_conf *c);
+struct rspamd_worker_conf *rspamd_config_new_worker (struct rspamd_config *cfg,
+ struct rspamd_worker_conf *c);
+
/*
* Return a new metric structure, setting default and non-conflicting attributes
*/
@@ -598,15 +605,16 @@ void rspamd_config_init_metric (struct rspamd_config *cfg);
/*
* Return new symbols group definition
*/
-struct rspamd_symbols_group * rspamd_config_new_group (
+struct rspamd_symbols_group *rspamd_config_new_group (
struct rspamd_config *cfg,
const gchar *name);
+
/*
* Return a new statfile structure, setting default and non-conflicting attributes
*/
-struct rspamd_statfile_config * rspamd_config_new_statfile (
- struct rspamd_config *cfg,
- struct rspamd_statfile_config *c);
+struct rspamd_statfile_config *rspamd_config_new_statfile (
+ struct rspamd_config *cfg,
+ struct rspamd_statfile_config *c);
/*
* Register symbols of classifiers inside metrics
@@ -621,12 +629,12 @@ gboolean rspamd_config_check_statfiles (struct rspamd_classifier_config *cf);
/*
* Find classifier config by name
*/
-struct rspamd_classifier_config * rspamd_config_find_classifier (
- struct rspamd_config *cfg,
- const gchar *name);
+struct rspamd_classifier_config *rspamd_config_find_classifier (
+ struct rspamd_config *cfg,
+ const gchar *name);
void rspamd_ucl_add_conf_macros (struct ucl_parser *parser,
- struct rspamd_config *cfg);
+ struct rspamd_config *cfg);
void rspamd_ucl_add_conf_variables (struct ucl_parser *parser, GHashTable *vars);
@@ -681,8 +689,8 @@ gboolean rspamd_config_add_symbol_group (struct rspamd_config *cfg,
* @return TRUE if symbol has been inserted or FALSE if action already exists with higher priority
*/
gboolean rspamd_config_set_action_score (struct rspamd_config *cfg,
- const gchar *action_name,
- const ucl_object_t *obj);
+ const gchar *action_name,
+ const ucl_object_t *obj);
/**
* Check priority and maybe disable action completely
@@ -709,7 +717,7 @@ gboolean rspamd_config_maybe_disable_action (struct rspamd_config *cfg,
* @return TRUE if a module is enabled
*/
gboolean rspamd_config_is_module_enabled (struct rspamd_config *cfg,
- const gchar *module_name);
+ const gchar *module_name);
/*
* Get action from a string
@@ -719,8 +727,9 @@ gboolean rspamd_action_from_str (const gchar *data, gint *result);
/*
* Return textual representation of action enumeration
*/
-const gchar * rspamd_action_to_str (enum rspamd_action_type action);
-const gchar * rspamd_action_to_str_alt (enum rspamd_action_type action);
+const gchar *rspamd_action_to_str (enum rspamd_action_type action);
+
+const gchar *rspamd_action_to_str_alt (enum rspamd_action_type action);
/*
* Resort all actions (needed to operate with thresholds)
@@ -736,11 +745,12 @@ void rspamd_actions_sort (struct rspamd_config *cfg);
* @return
*/
struct rspamd_radix_map_helper;
+
gboolean rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
- const ucl_object_t *obj,
- const gchar *description,
- struct rspamd_radix_map_helper **target,
- GError **err);
+ const ucl_object_t *obj,
+ const gchar *description,
+ struct rspamd_radix_map_helper **target,
+ GError **err);
/**
* Adds new settings id to be preprocessed
@@ -789,11 +799,11 @@ struct rspamd_config_settings_elt *rspamd_config_find_settings_name_ref (
* @param name
* @return
*/
-struct rspamd_action * rspamd_config_get_action (struct rspamd_config *cfg,
- const gchar *name);
+struct rspamd_action *rspamd_config_get_action (struct rspamd_config *cfg,
+ const gchar *name);
-struct rspamd_action * rspamd_config_get_action_by_type (struct rspamd_config *cfg,
- enum rspamd_action_type type);
+struct rspamd_action *rspamd_config_get_action_by_type (struct rspamd_config *cfg,
+ enum rspamd_action_type type);
#define msg_err_config(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
cfg->cfg_pool->tag.tagname, cfg->checksum, \
@@ -817,5 +827,8 @@ extern guint rspamd_config_log_id;
G_STRFUNC, \
__VA_ARGS__)
+#ifdef __cplusplus
+}
+#endif
#endif /* ifdef CFG_FILE_H */