-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#include "libmime/email_addr.h"
#include "libmime/lang_detection.h"
+#include <string>
+#include "contrib/ankerl/unordered_dense.h"
+#include "libutil/cxx/util.hxx"
+
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
struct rspamd_rcl_default_handler_data {
struct rspamd_rcl_struct_parser pd;
- gchar *key;
+ std::string key;
rspamd_rcl_default_handler_t handler;
- UT_hash_handle hh;
};
struct rspamd_rcl_section {
const gchar *name; /**< name of section */
const gchar *key_attr;
const gchar *default_key;
- rspamd_rcl_handler_t handler; /**< handler of section attributes */
- enum ucl_type type; /**< type of attribute */
- gboolean required; /**< whether this param is required */
- gboolean strict_type; /**< whether we need strict type */
- UT_hash_handle hh; /** hash handle */
- struct rspamd_rcl_section *subsections; /**< hash table of subsections */
- struct rspamd_rcl_default_handler_data *default_parser; /**< generic parsing fields */
- rspamd_rcl_section_fin_t fin; /** called at the end of section parsing */
+ rspamd_rcl_handler_t handler; /**< handler of section attributes */
+ enum ucl_type type; /**< type of attribute */
+ gboolean required; /**< whether this param is required */
+ gboolean strict_type; /**< whether we need strict type */
+ ankerl::unordered_dense::map<std::string, struct rspamd_rcl_section> subsections;
+ ankerl::unordered_dense::map<std::string, struct rspamd_rcl_default_handler_data> default_parser; /**< generic parsing fields */
+ rspamd_rcl_section_fin_t fin; /** called at the end of section parsing */
gpointer fin_ud;
ucl_object_t *doc_ref; /**< reference to the section's documentation */
};
gpointer def_ud;
};
-static gboolean rspamd_rcl_process_section(struct rspamd_config *cfg,
- struct rspamd_rcl_section *sec,
- gpointer ptr, const ucl_object_t *obj, rspamd_mempool_t *pool,
- GError **err);
+static bool rspamd_rcl_process_section(struct rspamd_config *cfg,
+ struct rspamd_rcl_section *sec,
+ gpointer ptr, const ucl_object_t *obj, rspamd_mempool_t *pool,
+ GError **err);
+static bool
+rspamd_rcl_section_parse_defaults(struct rspamd_config *cfg,
+ const struct rspamd_rcl_section §ion,
+ rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ptr,
+ GError **err);
/*
* Common section handlers
GError **err)
{
const ucl_object_t *val;
- const gchar *facility = NULL, *log_type = NULL, *log_level = NULL;
- struct rspamd_config *cfg = ud;
+ const gchar *facility = nullptr, *log_type = nullptr, *log_level = nullptr;
+ auto *cfg = (struct rspamd_config *) ud;
val = ucl_object_lookup(obj, "type");
- if (val != NULL && ucl_object_tostring_safe(val, &log_type)) {
+ if (val != nullptr && ucl_object_tostring_safe(val, &log_type)) {
if (g_ascii_strcasecmp(log_type, "file") == 0) {
/* Need to get filename */
val = ucl_object_lookup(obj, "filename");
- if (val == NULL || val->type != UCL_STRING) {
+ if (val == nullptr || val->type != UCL_STRING) {
g_set_error(err,
CFG_RCL_ERROR,
ENOENT,
cfg->log_facility = LOG_DAEMON;
cfg->log_type = RSPAMD_LOG_SYSLOG;
val = ucl_object_lookup(obj, "facility");
- if (val != NULL && ucl_object_tostring_safe(val, &facility)) {
+ if (val != nullptr && ucl_object_tostring_safe(val, &facility)) {
if (g_ascii_strcasecmp(facility, "LOG_AUTH") == 0 ||
g_ascii_strcasecmp(facility, "auth") == 0) {
cfg->log_facility = LOG_AUTH;
/* Handle log level */
val = ucl_object_lookup(obj, "level");
- if (val != NULL && ucl_object_tostring_safe(val, &log_level)) {
+ if (val != nullptr && 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;
}
}
/* Handle flags */
- val = ucl_object_lookup_any(obj, "color", "log_color", NULL);
+ val = ucl_object_lookup_any(obj, "color", "log_color", nullptr);
if (val && ucl_object_toboolean(val)) {
cfg->log_flags |= RSPAMD_LOG_FLAG_COLOR;
}
- val = ucl_object_lookup_any(obj, "severity", "log_severity", NULL);
+ val = ucl_object_lookup_any(obj, "severity", "log_severity", nullptr);
if (val && ucl_object_toboolean(val)) {
cfg->log_flags |= RSPAMD_LOG_FLAG_SEVERITY;
}
- val = ucl_object_lookup_any(obj, "systemd", "log_systemd", NULL);
+ val = ucl_object_lookup_any(obj, "systemd", "log_systemd", nullptr);
if (val && ucl_object_toboolean(val)) {
cfg->log_flags |= RSPAMD_LOG_FLAG_SYSTEMD;
}
cfg->log_flags |= RSPAMD_LOG_FLAG_RE_CACHE;
}
- val = ucl_object_lookup_any(obj, "usec", "log_usec", NULL);
+ val = ucl_object_lookup_any(obj, "usec", "log_usec", nullptr);
if (val && ucl_object_toboolean(val)) {
cfg->log_flags |= RSPAMD_LOG_FLAG_USEC;
}
- return rspamd_rcl_section_parse_defaults(cfg, section, cfg->cfg_pool, obj,
- cfg, err);
+ return rspamd_rcl_section_parse_defaults(cfg, *section, cfg->cfg_pool, obj,
+ (void *) cfg, err);
}
static gboolean
struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *dns, *upstream, *neighbours;
- struct rspamd_config *cfg = ud;
+ auto *cfg = (struct rspamd_config *) ud;
struct rspamd_rcl_section *dns_section, *upstream_section, *neighbours_section;
- HASH_FIND_STR(section->subsections, "dns", dns_section);
+ auto maybe_subsection = rspamd::find_map(section->subsections, "dns");
dns = ucl_object_lookup(obj, "dns");
- if (dns_section != NULL && dns != NULL) {
+ if (maybe_subsection && dns != nullptr) {
if (!rspamd_rcl_section_parse_defaults(cfg,
- dns_section, cfg->cfg_pool, dns,
+ &maybe_subsection.value().get(), cfg->cfg_pool, dns,
cfg, err)) {
return FALSE;
}
HASH_FIND_STR(section->subsections, "upstream", upstream_section);
- upstream = ucl_object_lookup_any(obj, "upstream", "upstreams", NULL);
- if (upstream_section != NULL && upstream != NULL) {
+ upstream = ucl_object_lookup_any(obj, "upstream", "upstreams", nullptr);
+ if (upstream_section != nullptr && upstream != nullptr) {
if (!rspamd_rcl_section_parse_defaults(cfg,
upstream_section, cfg->cfg_pool,
upstream, cfg, err)) {
HASH_FIND_STR(section->subsections, "neighbours", neighbours_section);
neighbours = ucl_object_lookup(obj, "neighbours");
- if (neighbours_section != NULL && neighbours != NULL) {
+ if (neighbours_section != nullptr && neighbours != nullptr) {
const ucl_object_t *cur;
LL_FOREACH(neighbours, cur)
const ucl_object_t *val, *elt;
struct rspamd_rcl_section *subsection;
struct rspamd_rcl_symbol_data sd;
- const gchar *description = NULL;
+ const gchar *description = nullptr;
- g_assert(key != NULL);
+ g_assert(key != nullptr);
gr = g_hash_table_lookup(cfg->groups, key);
- if (gr == NULL) {
+ if (gr == nullptr) {
gr = rspamd_config_new_group(cfg, key);
}
return FALSE;
}
- if ((elt = ucl_object_lookup(obj, "one_shot")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "one_shot")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "disabled")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "disabled")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "enabled")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "enabled")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "public")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "public")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "private")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "private")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
/* Handle symbols */
val = ucl_object_lookup(obj, "symbols");
- if (val != NULL && ucl_object_type(val) == UCL_OBJECT) {
+ if (val != nullptr && ucl_object_type(val) == UCL_OBJECT) {
HASH_FIND_STR(section->subsections, "symbols", subsection);
- g_assert(subsection != NULL);
+ g_assert(subsection != nullptr);
if (!rspamd_rcl_process_section(cfg, subsection, &sd, val,
pool, err)) {
struct rspamd_rcl_symbol_data *sd = ud;
struct rspamd_config *cfg;
const ucl_object_t *elt;
- const gchar *description = NULL;
+ const gchar *description = nullptr;
gdouble score = NAN;
guint priority = 1, flags = 0;
gint nshots = 0;
- g_assert(key != NULL);
+ g_assert(key != nullptr);
cfg = sd->cfg;
- if ((elt = ucl_object_lookup(obj, "one_shot")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "one_shot")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "any_shot")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "any_shot")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "one_param")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "one_param")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "ignore")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "ignore")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "enabled")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "enabled")) != nullptr) {
if (ucl_object_type(elt) != UCL_BOOLEAN) {
g_set_error(err,
CFG_RCL_ERROR,
}
}
- if ((elt = ucl_object_lookup(obj, "nshots")) != NULL) {
+ if ((elt = ucl_object_lookup(obj, "nshots")) != nullptr) {
if (ucl_object_type(elt) != UCL_FLOAT && ucl_object_type(elt) != UCL_INT) {
g_set_error(err,
CFG_RCL_ERROR,
nshots = ucl_object_toint(elt);
}
- elt = ucl_object_lookup_any(obj, "score", "weight", NULL);
+ elt = ucl_object_lookup_any(obj, "score", "weight", nullptr);
if (elt) {
if (ucl_object_type(elt) != UCL_FLOAT && ucl_object_type(elt) != UCL_INT) {
g_set_error(err,
}
else {
rspamd_config_add_symbol(cfg, key, score,
- description, NULL, flags, priority, nshots);
+ description, nullptr, flags, priority, nshots);
}
elt = ucl_object_lookup(obj, "groups");
gr_it = ucl_object_iterate_new(elt);
- while ((cur_gr = ucl_object_iterate_safe(gr_it, true)) != NULL) {
+ while ((cur_gr = ucl_object_iterate_safe(gr_it, true)) != nullptr) {
rspamd_config_add_symbol_group(cfg, key,
ucl_object_tostring(cur_gr));
}
it = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_safe(it, true)) != NULL) {
+ while ((cur = ucl_object_iterate_safe(it, true)) != nullptr) {
gint type = ucl_object_type(cur);
if (type == UCL_NULL) {
{
const ucl_object_t *val, *cur, *cur_obj;
ucl_object_t *robj;
- ucl_object_iter_t it = NULL;
+ ucl_object_iter_t it = nullptr;
const gchar *worker_type, *worker_bind;
struct rspamd_config *cfg = ud;
GQuark qtype;
struct rspamd_worker_param_parser *whandler;
struct rspamd_worker_param_key srch;
- g_assert(key != NULL);
+ g_assert(key != nullptr);
worker_type = key;
qtype = g_quark_try_string(worker_type);
if (qtype != 0) {
- wrk = rspamd_config_new_worker(cfg, NULL);
+ wrk = rspamd_config_new_worker(cfg, nullptr);
wrk->options = ucl_object_copy(obj);
wrk->worker = rspamd_get_worker_by_type(cfg, qtype);
- if (wrk->worker == NULL) {
+ if (wrk->worker == nullptr) {
g_set_error(err,
CFG_RCL_ERROR,
EINVAL,
return TRUE;
}
- val = ucl_object_lookup_any(obj, "bind_socket", "listen", "bind", NULL);
+ val = ucl_object_lookup_any(obj, "bind_socket", "listen", "bind", nullptr);
/* This name is more logical */
- if (val != NULL) {
+ if (val != nullptr) {
it = ucl_object_iterate_new(val);
- while ((cur = ucl_object_iterate_safe(it, true)) != NULL) {
+ while ((cur = ucl_object_iterate_safe(it, true)) != nullptr) {
if (!ucl_object_tostring_safe(cur, &worker_bind)) {
continue;
}
/* Parse other attributes */
wparser = g_hash_table_lookup(cfg->wrk_parsers, &qtype);
- if (wparser != NULL && obj->type == UCL_OBJECT) {
+ if (wparser != nullptr && obj->type == UCL_OBJECT) {
it = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != NULL) {
+ while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != nullptr) {
srch.name = ucl_object_key(cur);
srch.ptr = wrk->ctx; /* XXX: is it valid? Update! no, it is not valid, omfg... */
whandler = g_hash_table_lookup(wparser->parsers, &srch);
- if (whandler != NULL) {
+ if (whandler != nullptr) {
LL_FOREACH(cur, cur_obj)
{
ucl_object_iterate_free(it);
- if (wparser->def_obj_parser != NULL) {
+ if (wparser->def_obj_parser != nullptr) {
robj = ucl_object_ref(obj);
if (!wparser->def_obj_parser(robj, wparser->def_ud)) {
if (lua_dir && lua_file) {
cur_dir = g_malloc(PATH_MAX);
- if (getcwd(cur_dir, PATH_MAX) != NULL && chdir(lua_dir) != -1) {
+ if (getcwd(cur_dir, PATH_MAX) != nullptr && chdir(lua_dir) != -1) {
/* Push traceback function */
lua_pushcfunction(L, &rspamd_lua_traceback);
err_idx = lua_gettop(L);
cur_mod->name);
ext_pos = strstr(cur_mod->name, ".lua");
- if (ext_pos != NULL) {
+ if (ext_pos != nullptr) {
*ext_pos = '\0';
}
if (modules_seen) {
seen_mod = g_hash_table_lookup(modules_seen, cur_mod->name);
- if (seen_mod != NULL) {
+ if (seen_mod != nullptr) {
msg_info_config("already seen module %s at %s, skip %s",
cur_mod->name, seen_mod->path, cur_mod->path);
continue;
}
}
- if (cfg->script_modules == NULL) {
+ if (cfg->script_modules == nullptr) {
cfg->script_modules = g_list_append(cfg->script_modules,
cur_mod);
rspamd_mempool_add_destructor(cfg->cfg_pool,
cur_mod->name);
ext_pos = strstr(cur_mod->name, ".lua");
- if (ext_pos != NULL) {
+ if (ext_pos != nullptr) {
*ext_pos = '\0';
}
if (modules_seen) {
seen_mod = g_hash_table_lookup(modules_seen, cur_mod->name);
- if (seen_mod != NULL) {
+ if (seen_mod != nullptr) {
msg_info_config("already seen module %s at %s, skip %s",
cur_mod->name, seen_mod->path, cur_mod->path);
}
}
- if (cfg->script_modules == NULL) {
+ if (cfg->script_modules == nullptr) {
cfg->script_modules = g_list_append(cfg->script_modules,
cur_mod);
rspamd_mempool_add_destructor(cfg->cfg_pool,
}
else if (ucl_object_tostring_safe(obj, &data)) {
if (!rspamd_rcl_add_lua_plugins_path(cfg,
- rspamd_mempool_strdup(cfg->cfg_pool, data), TRUE, NULL, err)) {
+ rspamd_mempool_strdup(cfg->cfg_pool, data), TRUE, nullptr, err)) {
return FALSE;
}
}
struct rspamd_statfile_config *st;
GList *labels;
- g_assert(key != NULL);
+ g_assert(key != nullptr);
cfg = stud->cfg;
ccf = stud->ccf;
- st = rspamd_config_new_statfile(cfg, NULL);
+ st = rspamd_config_new_statfile(cfg, nullptr);
st->symbol = rspamd_mempool_strdup(cfg->cfg_pool, key);
if (rspamd_rcl_section_parse_defaults(cfg, section, pool, obj, st, err)) {
ccf->statfiles = rspamd_mempool_glist_prepend(pool, ccf->statfiles, st);
- if (st->label != NULL) {
+ if (st->label != nullptr) {
labels = g_hash_table_lookup(ccf->labels, st->label);
- if (labels != NULL) {
+ if (labels != nullptr) {
labels = g_list_append(labels, st);
}
else {
g_hash_table_insert(ccf->labels, st->label,
- g_list_prepend(NULL, st));
+ g_list_prepend(nullptr, st));
}
}
- if (st->symbol != NULL) {
+ if (st->symbol != nullptr) {
g_hash_table_insert(cfg->classifiers_symbols, st->symbol, st);
}
else {
st->clcf = ccf;
val = ucl_object_lookup(obj, "spam");
- if (val == NULL) {
+ if (val == nullptr) {
msg_info_config(
"statfile %s has no explicit 'spam' setting, trying to guess by symbol",
st->symbol);
GError **err)
{
const ucl_object_t *val, *cur;
- ucl_object_iter_t it = NULL;
+ ucl_object_iter_t it = nullptr;
struct rspamd_config *cfg = ud;
struct statfile_parser_data stud;
const gchar *st_key;
struct rspamd_classifier_config *ccf;
gboolean res = TRUE;
struct rspamd_rcl_section *stat_section;
- struct rspamd_tokenizer_config *tkcf = NULL;
+ struct rspamd_tokenizer_config *tkcf = nullptr;
lua_State *L = cfg->lua_state;
- g_assert(key != NULL);
- ccf = rspamd_config_new_classifier(cfg, NULL);
+ g_assert(key != nullptr);
+ ccf = rspamd_config_new_classifier(cfg, nullptr);
ccf->classifier = rspamd_mempool_strdup(cfg->cfg_pool, key);
HASH_FIND_STR(section->subsections, "statfile", stat_section);
- if (ccf->classifier == NULL) {
+ if (ccf->classifier == nullptr) {
ccf->classifier = "bayes";
}
- if (ccf->name == NULL) {
+ if (ccf->name == nullptr) {
ccf->name = ccf->classifier;
}
it = ucl_object_iterate_new(obj);
- while ((val = ucl_object_iterate_safe(it, true)) != NULL && res) {
+ while ((val = ucl_object_iterate_safe(it, true)) != nullptr && res) {
st_key = ucl_object_key(val);
- if (st_key != NULL) {
+ if (st_key != nullptr) {
if (g_ascii_strcasecmp(st_key, "statfile") == 0) {
LL_FOREACH(val, cur)
{
}
else if (ucl_object_type(val) == UCL_OBJECT) {
cur = ucl_object_lookup(val, "name");
- if (cur != NULL) {
+ if (cur != nullptr) {
tkcf->name = ucl_object_tostring(cur);
tkcf->opts = val;
}
else {
cur = ucl_object_lookup(val, "type");
- if (cur != NULL) {
+ if (cur != nullptr) {
tkcf->name = ucl_object_tostring(cur);
tkcf->opts = val;
}
msg_err_config("fatal configuration error, cannot parse statfile definition");
}
- if (tkcf == NULL) {
+ if (tkcf == nullptr) {
tkcf = rspamd_mempool_alloc0(cfg->cfg_pool, sizeof(*tkcf));
- tkcf->name = NULL;
+ tkcf->name = nullptr;
}
ccf->tokenizer = tkcf;
/* Handle lua conditions */
- val = ucl_object_lookup_any(obj, "learn_condition", NULL);
+ val = ucl_object_lookup_any(obj, "learn_condition", nullptr);
if (val) {
LL_FOREACH(val, cur)
}
}
- val = ucl_object_lookup_any(obj, "classify_condition", NULL);
+ val = ucl_object_lookup_any(obj, "classify_condition", nullptr);
if (val) {
LL_FOREACH(val, cur)
void *composite;
const gchar *composite_name;
- g_assert(key != NULL);
+ g_assert(key != nullptr);
composite_name = key;
const ucl_object_t *val = ucl_object_lookup(obj, "enabled");
- if (val != NULL && !ucl_object_toboolean(val)) {
+ if (val != nullptr && !ucl_object_toboolean(val)) {
msg_info_config("composite %s is disabled", composite_name);
return TRUE;
}
if ((composite = rspamd_composites_manager_add_from_ucl(cfg->composites_manager,
- composite_name, obj)) != NULL) {
+ composite_name, obj)) != nullptr) {
rspamd_symcache_add_symbol(cfg->cache, composite_name, 0,
- NULL, composite, SYMBOL_TYPE_COMPOSITE, -1);
+ nullptr, composite, SYMBOL_TYPE_COMPOSITE, -1);
}
- return composite != NULL;
+ return composite != nullptr;
}
static gboolean
struct rspamd_rcl_section *section,
GError **err)
{
- ucl_object_iter_t it = NULL;
+ ucl_object_iter_t it = nullptr;
const ucl_object_t *cur;
gboolean success = TRUE;
GString *urlstr;
const gchar *p;
- if (key == NULL) {
+ if (key == nullptr) {
g_set_error(err,
CFG_RCL_ERROR,
EINVAL,
hostval = ucl_object_lookup(obj, "host");
- if (hostval == NULL || ucl_object_type(hostval) != UCL_STRING) {
+ if (hostval == nullptr || ucl_object_type(hostval) != UCL_STRING) {
g_set_error(err,
CFG_RCL_ERROR,
EINVAL,
neigh = ucl_object_typed_new(UCL_OBJECT);
ucl_object_insert_key(neigh, ucl_object_copy(hostval), "host", 0, false);
- if ((p = strrchr(ucl_object_tostring(hostval), ':')) != NULL) {
+ if ((p = strrchr(ucl_object_tostring(hostval), ':')) != nullptr) {
if (g_ascii_isdigit(p[1])) {
has_port = TRUE;
}
}
- if (strstr(ucl_object_tostring(hostval), "://") != NULL) {
+ if (strstr(ucl_object_tostring(hostval), "://") != nullptr) {
has_proto = TRUE;
}
g_string_append(urlstr, ":11334");
}
- if (pathval == NULL) {
+ if (pathval == nullptr) {
g_string_append(urlstr, "/");
}
else {
new->type = type;
new->strict_type = strict_type;
- if (*top == NULL) {
- parent_doc = NULL;
- new->doc_ref = NULL;
+ if (*top == nullptr) {
+ parent_doc = nullptr;
+ new->doc_ref = nullptr;
}
else {
parent_doc = (*top)->doc_ref;
new->doc_ref = ucl_object_ref(rspamd_rcl_add_doc_obj(parent_doc,
- NULL,
+ nullptr,
name,
type,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0));
}
doc_string,
name,
type,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0));
HASH_ADD_KEYPTR(hh, *top, new_section->name, strlen(new_section->name), new_section);
nhandler->pd.offset = offset;
nhandler->pd.flags = flags;
- if (section->doc_ref != NULL) {
+ if (section->doc_ref != nullptr) {
rspamd_rcl_add_doc_obj(section->doc_ref,
doc_string,
name,
UCL_NULL,
handler,
flags,
- NULL,
+ nullptr,
0);
}
struct rspamd_rcl_section *
rspamd_rcl_config_init(struct rspamd_config *cfg, GHashTable *skip_sections)
{
- struct rspamd_rcl_section *new = NULL, *sub, *ssub;
+ struct rspamd_rcl_section *new = nullptr, *sub, *ssub;
/*
* Important notice:
*/
if (!(skip_sections && g_hash_table_lookup(skip_sections, "logging"))) {
sub = rspamd_rcl_add_section_doc(&new,
- "logging", NULL,
+ "logging", nullptr,
rspamd_rcl_logging_handler,
UCL_OBJECT,
FALSE,
"Enable colored output (for console logging)",
"log_color",
UCL_BOOLEAN,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0);
rspamd_rcl_add_doc_by_path(cfg,
"logging",
"Enable severity logging output (e.g. [error] or [warning])",
"log_severity",
UCL_BOOLEAN,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0);
rspamd_rcl_add_doc_by_path(cfg,
"logging",
"Enable systemd compatible logging",
"systemd",
UCL_BOOLEAN,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0);
rspamd_rcl_add_doc_by_path(cfg,
"logging",
"Write statistics of regexp processing to log (useful for hyperscan)",
"log_re_cache",
UCL_BOOLEAN,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0);
rspamd_rcl_add_doc_by_path(cfg,
"logging",
"Use microseconds resolution for timestamps",
"log_usec",
UCL_BOOLEAN,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0);
}
if (!(skip_sections && g_hash_table_lookup(skip_sections, "options"))) {
* Options section
*/
sub = rspamd_rcl_add_section_doc(&new,
- "options", NULL,
+ "options", nullptr,
rspamd_rcl_options_handler,
UCL_OBJECT,
FALSE,
rspamd_rcl_parse_struct_string,
G_STRUCT_OFFSET(struct rspamd_config, ssl_ciphers),
0,
- "List of ssl ciphers (e.g. HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4)");
+ "List of ssl ciphers (e.g. HIGH:!anullptr:!kRSA:!PSK:!SRP:!MD5:!RC4)");
rspamd_rcl_add_default_handler(sub,
"max_message",
rspamd_rcl_parse_struct_integer,
"List of members of Rspamd cluster");
/* New DNS configuration */
- ssub = rspamd_rcl_add_section_doc(&sub->subsections, "dns", NULL, NULL,
+ ssub = rspamd_rcl_add_section_doc(&sub->subsections, "dns", nullptr, nullptr,
UCL_OBJECT, FALSE, TRUE,
cfg->doc_strings,
"Options for DNS resolver");
/* New upstreams configuration */
- ssub = rspamd_rcl_add_section_doc(&sub->subsections, "upstream", NULL, NULL,
+ ssub = rspamd_rcl_add_section_doc(&sub->subsections, "upstream", nullptr, nullptr,
UCL_OBJECT, FALSE, TRUE,
cfg->doc_strings,
"Upstreams configuration parameters");
* Symbols and actions sections
*/
sub = rspamd_rcl_add_section_doc(&new,
- "actions", NULL,
+ "actions", nullptr,
rspamd_rcl_actions_handler,
UCL_OBJECT,
FALSE,
* Modules handler
*/
sub = rspamd_rcl_add_section_doc(&new,
- "modules", NULL,
+ "modules", nullptr,
rspamd_rcl_modules_handler,
UCL_OBJECT,
FALSE,
cfg->doc_strings,
"Rspamd composite symbols");
sub = rspamd_rcl_add_section_doc(&new,
- "composites", NULL,
+ "composites", nullptr,
rspamd_rcl_composites_handler,
UCL_OBJECT,
FALSE,
* Lua handler
*/
sub = rspamd_rcl_add_section_doc(&new,
- "lua", NULL,
+ "lua", nullptr,
rspamd_rcl_lua_handler,
UCL_STRING,
FALSE,
rspamd_rcl_config_get_section(struct rspamd_rcl_section *top,
const char *path)
{
- struct rspamd_rcl_section *cur, *found = NULL;
+ struct rspamd_rcl_section *cur, *found = nullptr;
char **path_components;
gint ncomponents, i;
- if (path == NULL) {
+ if (path == nullptr) {
return top;
}
cur = top;
for (i = 0; i < ncomponents; i++) {
- if (cur == NULL) {
+ if (cur == nullptr) {
g_strfreev(path_components);
- return NULL;
+ return nullptr;
}
HASH_FIND_STR(cur, path_components[i], found);
- if (found == NULL) {
+ if (found == nullptr) {
g_strfreev(path_components);
- return NULL;
+ return nullptr;
}
cur = found;
}
return found;
}
-static gboolean
+static bool
rspamd_rcl_process_section(struct rspamd_config *cfg,
struct rspamd_rcl_section *sec,
gpointer ptr, const ucl_object_t *obj, rspamd_mempool_t *pool,
{
ucl_object_iter_t it;
const ucl_object_t *cur;
- gboolean is_nested = TRUE;
- const gchar *key = NULL;
+ auto is_nested = true;
+ const gchar *key = nullptr;
- g_assert(obj != NULL);
- g_assert(sec->handler != NULL);
+ g_assert(obj != nullptr);
+ g_assert(sec->handler != nullptr);
- if (sec->key_attr != NULL) {
+ if (sec->key_attr != nullptr) {
it = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != NULL) {
+ while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != nullptr) {
if (ucl_object_type(cur) != UCL_OBJECT) {
- is_nested = FALSE;
+ is_nested = false;
break;
}
}
ucl_object_iterate_free(it);
}
else {
- is_nested = FALSE;
+ is_nested = false;
}
if (is_nested) {
/* Just reiterate on all subobjects */
it = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != NULL) {
+ while ((cur = ucl_object_iterate_full(it, UCL_ITERATE_EXPLICIT)) != nullptr) {
if (!sec->handler(pool, cur, ucl_object_key(cur), ptr, sec, err)) {
ucl_object_iterate_free(it);
- return FALSE;
+ return false;
}
}
ucl_object_iterate_free(it);
- return TRUE;
+ return true;
}
else {
- if (sec->key_attr != NULL) {
+ if (sec->key_attr != nullptr) {
/* First of all search for required attribute and use it as a key */
cur = ucl_object_lookup(obj, sec->key_attr);
- if (cur == NULL) {
- if (sec->default_key == NULL) {
+ if (cur == nullptr) {
+ if (sec->default_key == nullptr) {
g_set_error(err, CFG_RCL_ERROR, EINVAL, "required attribute "
"'%s' is missing for section '%s', current key: %s",
sec->key_attr,
sec->name,
ucl_object_emit(obj, UCL_EMIT_CONFIG));
- return FALSE;
+ return false;
}
else {
msg_info("using default key '%s' for mandatory field '%s' "
" is not a string for section %s",
sec->key_attr, sec->name);
- return FALSE;
+ return false;
}
else {
key = ucl_object_tostring(cur);
{
HASH_FIND_STR(top, ucl_object_key(cur_obj), found_sec);
- if (found_sec == NULL) {
- if (cur->handler != NULL) {
+ if (found_sec == nullptr) {
+ if (cur->handler != nullptr) {
if (!rspamd_rcl_process_section(cfg, cur, ptr, cur_obj,
pool, err)) {
return FALSE;
}
else {
found = ucl_object_lookup(obj, cur->name);
- if (found == NULL) {
+ if (found == nullptr) {
if (cur->required) {
g_set_error(err, CFG_RCL_ERROR, ENOENT,
"required section %s is missing", cur->name);
LL_FOREACH(found, cur_obj)
{
- if (cur->handler != NULL) {
+ if (cur->handler != nullptr) {
if (!rspamd_rcl_process_section(cfg, cur, ptr, cur_obj,
pool, err)) {
return FALSE;
return TRUE;
}
-gboolean
+static bool
rspamd_rcl_section_parse_defaults(struct rspamd_config *cfg,
- struct rspamd_rcl_section *section,
+ const struct rspamd_rcl_section §ion,
rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ptr,
GError **err)
{
- const ucl_object_t *found, *cur_obj;
- struct rspamd_rcl_default_handler_data *cur, *tmp;
if (obj->type != UCL_OBJECT) {
g_set_error(err,
EINVAL,
"default configuration must be an object for section %s "
"(actual type is %s)",
- section->name, ucl_object_type_to_string(obj->type));
+ section.name, ucl_object_type_to_string(ucl_object_type(obj)));
return FALSE;
}
- HASH_ITER(hh, section->default_parser, cur, tmp)
- {
- found = ucl_object_lookup(obj, cur->key);
- if (found != NULL) {
- cur->pd.user_struct = ptr;
- cur->pd.cfg = cfg;
+ for (const auto &cur: section.default_parser) {
+ const auto *found = ucl_object_lookup(obj, cur.first.c_str());
+ if (found != nullptr) {
+ auto new_pd = cur.second.pd;
+ new_pd.user_struct = ptr;
+ new_pd.cfg = cfg;
+ const auto *cur_obj = found;
LL_FOREACH(found, cur_obj)
{
- if (!cur->handler(pool, cur_obj, &cur->pd, section, err)) {
+ if (!cur.second.handler(pool, cur_obj, &new_pd, const_cast<rspamd_rcl_section *>(§ion), err)) {
return FALSE;
}
- if (!(cur->pd.flags & RSPAMD_CL_FLAG_MULTIPLE)) {
+ if (!(new_pd.flags & RSPAMD_CL_FLAG_MULTIPLE)) {
break;
}
}
struct rspamd_rcl_section *section,
GError **err)
{
- struct rspamd_rcl_struct_parser *pd = ud;
- gchar **target;
+ auto *pd = (struct rspamd_rcl_struct_parser *) ud;
const gsize num_str_len = 32;
- target = (gchar **) (((gchar *) pd->user_struct) + pd->offset);
+ auto target = (gchar **) (((gchar *) pd->user_struct) + pd->offset);
switch (obj->type) {
case UCL_STRING:
*target =
rspamd_mempool_strdup(pool, ucl_copy_value_trash(obj));
break;
case UCL_INT:
- *target = rspamd_mempool_alloc(pool, num_str_len);
+ *target = (gchar *) rspamd_mempool_alloc(pool, num_str_len);
rspamd_snprintf(*target, num_str_len, "%L", obj->value.iv);
break;
case UCL_FLOAT:
- *target = rspamd_mempool_alloc(pool, num_str_len);
+ *target = (gchar *) rspamd_mempool_alloc(pool, num_str_len);
rspamd_snprintf(*target, num_str_len, "%f", obj->value.dv);
break;
case UCL_BOOLEAN:
- *target = rspamd_mempool_alloc(pool, num_str_len);
+ *target = (gchar *) rspamd_mempool_alloc(pool, num_str_len);
rspamd_snprintf(*target, num_str_len, "%s",
((gboolean) obj->value.iv) ? "true" : "false");
break;
case UCL_NULL:
/* String is enforced to be null */
- *target = NULL;
+ *target = nullptr;
break;
default:
g_set_error(err,
if (obj->type == UCL_OBJECT) {
kp = rspamd_keypair_from_ucl(obj);
- if (kp != NULL) {
+ if (kp != nullptr) {
rspamd_mempool_add_destructor(pool,
(rspamd_mempool_destruct_t) rspamd_keypair_unref, kp);
*target = kp;
pk = rspamd_pubkey_from_base32(str, len, keypair_type,
keypair_mode);
- if (pk != NULL) {
+ if (pk != nullptr) {
*target = pk;
}
else {
d.p = *target;
if (is_hash) {
- if (d.hv == NULL) {
+ if (d.hv == nullptr) {
d.hv = g_hash_table_new(rspamd_str_hash, rspamd_str_equal);
rspamd_mempool_add_destructor(pool,
(rspamd_mempool_destruct_t) g_hash_table_unref, d.hv);
gchar *val, **strvec, **cvec;
const ucl_object_t *cur;
const gsize num_str_len = 32;
- ucl_object_iter_t iter = NULL;
+ ucl_object_iter_t iter = nullptr;
gboolean is_hash, need_destructor = TRUE;
is_hash = pd->flags & RSPAMD_CL_FLAG_STRING_LIST_HASH;
target = (gpointer *) (((gchar *) pd->user_struct) + pd->offset);
- if (!is_hash && *target != NULL) {
+ if (!is_hash && *target != nullptr) {
need_destructor = FALSE;
}
iter = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_safe(iter, true)) != NULL) {
+ while ((cur = ucl_object_iterate_safe(iter, true)) != nullptr) {
switch (cur->type) {
case UCL_STRING:
strvec = g_strsplit_set(ucl_object_tostring(cur), ",", -1);
#if 0
/* WTF: why don't we allow empty list here?? */
- if (*target == NULL) {
+ if (*target == nullptr) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
}
#endif
- if (!is_hash && *target != NULL) {
+ if (!is_hash && *target != nullptr) {
*target = g_list_reverse(*target);
if (need_destructor) {
GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
- GPtrArray **target, *tmp_addr = NULL;
+ GPtrArray **target, *tmp_addr = nullptr;
const gchar *val;
ucl_object_iter_t it;
const ucl_object_t *cur;
target = (GPtrArray **) (((gchar *) pd->user_struct) + pd->offset);
it = ucl_object_iterate_new(obj);
- while ((cur = ucl_object_iterate_safe(it, true)) != NULL) {
+ while ((cur = ucl_object_iterate_safe(it, true)) != nullptr) {
if (ucl_object_type(cur) == UCL_STRING) {
val = ucl_object_tostring(obj);
tmp_addr = rspamd_email_address_from_mime(pool, val,
nparser = g_hash_table_lookup(cfg->wrk_parsers, &type);
- if (nparser == NULL) {
- rspamd_rcl_register_worker_parser(cfg, type, NULL, NULL);
+ if (nparser == nullptr) {
+ rspamd_rcl_register_worker_parser(cfg, type, nullptr, nullptr);
nparser = g_hash_table_lookup(cfg->wrk_parsers, &type);
- g_assert(nparser != NULL);
+ g_assert(nparser != nullptr);
}
srch.name = name;
srch.ptr = target;
nhandler = g_hash_table_lookup(nparser->parsers, &srch);
- if (nhandler != NULL) {
+ if (nhandler != nullptr) {
msg_warn_config(
"handler for parameter %s is already registered for worker type %s",
name,
doc_workers = ucl_object_lookup(cfg->doc_strings, "workers");
- if (doc_workers == NULL) {
+ if (doc_workers == nullptr) {
doc_obj = ucl_object_typed_new(UCL_OBJECT);
ucl_object_insert_key(cfg->doc_strings, doc_obj, "workers", 0, false);
doc_workers = doc_obj;
doc_target = ucl_object_lookup(doc_workers, g_quark_to_string(type));
- if (doc_target == NULL) {
+ if (doc_target == nullptr) {
doc_obj = ucl_object_typed_new(UCL_OBJECT);
ucl_object_insert_key((ucl_object_t *) doc_workers, doc_obj,
g_quark_to_string(type), 0, true);
UCL_NULL,
handler,
flags,
- NULL,
+ nullptr,
0);
}
nparser = g_hash_table_lookup(cfg->wrk_parsers, &type);
- if (nparser == NULL) {
+ if (nparser == nullptr) {
/* Allocate new parser for this worker */
nparser =
rspamd_mempool_alloc0(cfg->cfg_pool,
gchar str[PATH_MAX];
static const char *transform_script = "lua_cfg_transform";
- g_assert(L != NULL);
+ g_assert(L != nullptr);
rspamd_snprintf(str, sizeof(str), "return require \"%s\"",
transform_script);
unsigned char **destination, size_t *dest_len,
void *user_data)
{
- GError *err = NULL;
+ GError *err = nullptr;
struct rspamd_cryptobox_keypair *kp = (struct rspamd_cryptobox_keypair *) user_data;
if (!rspamd_keypair_decrypt(kp, source, source_len,
struct ucl_emitter_functions f;
/* Calculate checksum */
- rspamd_cryptobox_hash_init(&hs, NULL, 0);
+ rspamd_cryptobox_hash_init(&hs, nullptr, 0);
f.ucl_emitter_append_character = rspamd_rcl_emitter_append_c;
f.ucl_emitter_append_double = rspamd_rcl_emitter_append_double;
f.ucl_emitter_append_int = rspamd_rcl_emitter_append_int;
f.ucl_emitter_append_len = rspamd_rcl_emitter_append_len;
- f.ucl_emitter_free_func = NULL;
+ f.ucl_emitter_free_func = nullptr;
f.ud = &hs;
ucl_object_emit_full(cfg->rcl_obj, UCL_EMIT_MSGPACK,
&f, cfg->config_comments);
gint fd;
struct ucl_parser *parser;
gchar keypair_path[PATH_MAX];
- struct rspamd_cryptobox_keypair *decrypt_keypair = NULL;
+ struct rspamd_cryptobox_keypair *decrypt_keypair = nullptr;
gchar *data;
if ((fd = open(filename, O_RDONLY)) == -1) {
return FALSE;
}
/* Now mmap this file to simplify reading process */
- if ((data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
+ if ((data = mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
g_set_error(err, cfg_rcl_error_quark(), errno,
"cannot mmap %s: %s", filename, strerror(errno));
close(fd);
kp_obj = ucl_parser_get_object(kp_parser);
- g_assert(kp_obj != NULL);
+ g_assert(kp_obj != nullptr);
decrypt_keypair = rspamd_keypair_from_ucl(kp_obj);
- if (decrypt_keypair == NULL) {
+ if (decrypt_keypair == nullptr) {
msg_err_config_forced("cannot load keypair from %s: invalid keypair",
keypair_path);
}
gboolean skip_jinja,
gchar **lua_env)
{
- GError *err = NULL;
+ GError *err = nullptr;
struct rspamd_rcl_section *top, *logger_section;
const ucl_object_t *logger_obj;
- rspamd_lua_set_path(cfg->lua_state, NULL, vars);
+ rspamd_lua_set_path(cfg->lua_state, nullptr, vars);
if (!rspamd_lua_set_env(cfg->lua_state, vars, lua_env, &err)) {
msg_err_config_forced("failed to set up environment: %e", err);
return FALSE;
}
- if (!rspamd_config_parse_ucl(cfg, filename, vars, NULL, NULL, skip_jinja, &err)) {
+ if (!rspamd_config_parse_ucl(cfg, filename, vars, nullptr, nullptr, skip_jinja, &err)) {
msg_err_config_forced("failed to load config: %e", err);
g_error_free(err);
return FALSE;
}
- top = rspamd_rcl_config_init(cfg, NULL);
+ top = rspamd_rcl_config_init(cfg, nullptr);
/* Add new paths if defined in options */
rspamd_lua_set_path(cfg->lua_state, cfg->rcl_obj, vars);
rspamd_lua_set_globals(cfg, cfg->lua_state);
rspamd_mempool_add_destructor(cfg->cfg_pool, rspamd_rcl_section_free, top);
- err = NULL;
+ err = nullptr;
- if (logger_fin != NULL) {
+ if (logger_fin != nullptr) {
HASH_FIND_STR(top, "logging", logger_section);
- if (logger_section != NULL) {
+ if (logger_section != nullptr) {
logger_obj = ucl_object_lookup_any(cfg->rcl_obj, "logging",
- "logger", NULL);
+ "logger", nullptr);
- if (logger_obj == NULL) {
+ if (logger_obj == nullptr) {
logger_fin(cfg->cfg_pool, logger_ud);
}
else {
gint flags)
{
gboolean has_example = FALSE, has_type = FALSE;
- const gchar *type = NULL;
+ const gchar *type = nullptr;
- if (ucl_object_lookup(doc_obj, "example") != NULL) {
+ if (ucl_object_lookup(doc_obj, "example") != nullptr) {
has_example = TRUE;
}
- if (ucl_object_lookup(doc_obj, "type") != NULL) {
+ if (ucl_object_lookup(doc_obj, "type") != nullptr) {
has_type = TRUE;
}
{
ucl_object_t *doc_obj;
- if (doc_target == NULL || doc_name == NULL) {
- return NULL;
+ if (doc_target == nullptr || doc_name == nullptr) {
+ return nullptr;
}
doc_obj = ucl_object_typed_new(UCL_OBJECT);
ucl_object_t *obj;
gchar **path_components, **comp;
- if (doc_path == NULL) {
+ if (doc_path == nullptr) {
/* Assume top object */
return rspamd_rcl_add_doc_obj(cfg->doc_strings,
doc_string,
else {
found = ucl_object_lookup_path(cfg->doc_strings, doc_path);
- if (found != NULL) {
+ if (found != nullptr) {
return rspamd_rcl_add_doc_obj((ucl_object_t *) found,
doc_string,
doc_name,
path_components = g_strsplit_set(doc_path, ".", -1);
cur = cfg->doc_strings;
- for (comp = path_components; *comp != NULL; comp++) {
+ for (comp = path_components; *comp != nullptr; comp++) {
if (ucl_object_type(cur) != UCL_OBJECT) {
msg_err_config("Bad path while lookup for '%s' at %s",
doc_path, *comp);
g_strfreev(path_components);
- return NULL;
+ return nullptr;
}
found = ucl_object_lookup(cur, *comp);
- if (found == NULL) {
+ if (found == nullptr) {
obj = ucl_object_typed_new(UCL_OBJECT);
ucl_object_insert_key((ucl_object_t *) cur,
obj,
ucl_object_t *top_doc, const ucl_object_t *obj,
const ucl_object_t *comments, gboolean is_top)
{
- ucl_object_iter_t it = NULL;
+ ucl_object_iter_t it = nullptr;
const ucl_object_t *cur, *cmt;
ucl_object_t *cur_doc;
if (ucl_object_type(obj) == UCL_OBJECT) {
- while ((cur = ucl_object_iterate(obj, &it, true)) != NULL) {
- cur_doc = NULL;
+ while ((cur = ucl_object_iterate(obj, &it, true)) != nullptr) {
+ cur_doc = nullptr;
- if ((cmt = ucl_comments_find(comments, cur)) != NULL) {
+ if ((cmt = ucl_comments_find(comments, cur)) != nullptr) {
cur_doc = rspamd_rcl_add_doc_obj(top_doc,
ucl_object_tostring(cmt), ucl_object_key(cur),
- ucl_object_type(cur), NULL, 0, NULL, FALSE);
+ ucl_object_type(cur), nullptr, 0, nullptr, FALSE);
}
if (ucl_object_type(cur) == UCL_OBJECT) {
}
}
else if (!is_top) {
- if ((cmt = ucl_comments_find(comments, obj)) != NULL) {
+ if ((cmt = ucl_comments_find(comments, obj)) != nullptr) {
rspamd_rcl_add_doc_obj(top_doc,
ucl_object_tostring(cmt), ucl_object_key(obj),
- ucl_object_type(obj), NULL, 0, NULL, FALSE);
+ ucl_object_type(obj), nullptr, 0, nullptr, FALSE);
}
}
}
ucl_parser_get_error(parser));
ucl_parser_free(parser);
- return NULL;
+ return nullptr;
}
top = ucl_parser_get_object(parser);
/* Add top object */
top_doc = rspamd_rcl_add_doc_by_path(cfg, root_path, doc_string,
- doc_name, ucl_object_type(top), NULL, 0, NULL, FALSE);
+ doc_name, ucl_object_type(top), nullptr, 0, nullptr, FALSE);
ucl_object_insert_key(top_doc,
ucl_object_fromstring_common(example_data, example_len, 0),
"example", 0, false);