aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_rcl.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-04 15:22:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-04 15:22:01 +0000
commitbed11b57981363694a6ed656941fe19b5acb1b87 (patch)
tree42ffea24963c930db6d8d6bfac28c9802e9f9cdf /src/libserver/cfg_rcl.c
parent84236da213a78afac84d1c1532aca94b7ef72b0c (diff)
downloadrspamd-bed11b57981363694a6ed656941fe19b5acb1b87.tar.gz
rspamd-bed11b57981363694a6ed656941fe19b5acb1b87.zip
Allow single string to be in a string list.
Diffstat (limited to 'src/libserver/cfg_rcl.c')
-rw-r--r--src/libserver/cfg_rcl.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 6074d637d..14ee4acca 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1864,41 +1864,49 @@ rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg,
target = (GList **)(((gchar *)pd->user_struct) + pd->offset);
- if (obj->type != UCL_ARRAY) {
- g_set_error (err,
- CFG_RCL_ERROR,
- EINVAL,
- "an array of strings is expected");
- return FALSE;
+ if (obj->type == UCL_STRING) {
+ /* Just a single string */
+ val = rspamd_mempool_strdup (cfg->cfg_pool,
+ ucl_copy_value_trash (obj));
+ *target = g_list_prepend (*target, val);
}
-
- while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) {
- switch (cur->type) {
- case UCL_STRING:
- val =
- rspamd_mempool_strdup (cfg->cfg_pool,
- ucl_copy_value_trash (cur));
- break;
- case UCL_INT:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%L", cur->value.iv);
- break;
- case UCL_FLOAT:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%f", cur->value.dv);
- break;
- case UCL_BOOLEAN:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%b", (gboolean)cur->value.iv);
- break;
- default:
- g_set_error (err,
+ else if (obj->type == UCL_ARRAY) {
+
+ while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) {
+ switch (cur->type) {
+ case UCL_STRING:
+ val =
+ rspamd_mempool_strdup (cfg->cfg_pool,
+ ucl_copy_value_trash (cur));
+ break;
+ case UCL_INT:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%L", cur->value.iv);
+ break;
+ case UCL_FLOAT:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%f", cur->value.dv);
+ break;
+ case UCL_BOOLEAN:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%b", (gboolean)cur->value.iv);
+ break;
+ default:
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot convert an object or array to string");
+ return FALSE;
+ }
+ *target = g_list_prepend (*target, val);
+ }
+ }
+ else {
+ g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
- "cannot convert an object or array to string");
- return FALSE;
- }
- *target = g_list_prepend (*target, val);
+ "an array of strings is expected");
+ return FALSE;
}
/* Add a destructor */