return TRUE;
}
+
+gboolean
+rspamd_rcl_parse_struct_string (struct config_file *cfg, rspamd_cl_object_t *obj,
+ gpointer ud, struct rspamd_rcl_section *section, GError **err)
+{
+ struct rspamd_rcl_struct_parser *pd = ud;
+ gchar **target;
+ const gsize num_str_len = 32;
+
+ target = (gchar **)(((gchar *)pd->user_struct) + pd->offset);
+ switch (obj->type) {
+ case RSPAMD_CL_STRING:
+ /* Direct assigning is safe, as object is likely linked to the cfg mem_pool */
+ *target = obj->value.sv;
+ break;
+ case RSPAMD_CL_INT:
+ *target = memory_pool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (*target, num_str_len, "%L", obj->value.iv);
+ break;
+ case RSPAMD_CL_FLOAT:
+ *target = memory_pool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (*target, num_str_len, "%f", obj->value.dv);
+ break;
+ case RSPAMD_CL_BOOLEAN:
+ *target = memory_pool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (*target, num_str_len, "%b", (gboolean)obj->value.iv);
+ break;
+ default:
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert object or array to string");
+ return FALSE;
+ }
+
+ return TRUE;
+}
gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top,
struct config_file *cfg, rspamd_cl_object_t *obj, GError **err);
+/**
+ * Here is a section of common handlers that accepts rcl_struct_parser
+ * which itself contains a struct pointer and the offset of a member in a
+ * specific structure
+ */
+struct rspamd_rcl_struct_parser {
+ gpointer user_struct;
+ goffset offset;
+};
+
+/**
+ * Parse a string field of a structure
+ * @param cfg config pointer
+ * @param obj object to parse
+ * @param ud struct_parser structure
+ * @param section the current section
+ * @param err error pointer
+ * @return TRUE if a string value has been successfully parsed
+ */
+gboolean rspamd_rcl_parse_struct_string (struct config_file *cfg, rspamd_cl_object_t *obj,
+ gpointer ud, struct rspamd_rcl_section *section, GError **err);
+
#endif /* CFG_RCL_H_ */