summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-29 15:39:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-29 15:39:35 +0100
commitddea9ac6acfa6bf3fb7aefa89c93ccf42cbe4c06 (patch)
tree4a98fa221564d5145b5c9eb20408702665d52306 /src
parent7ade35b5e8abb9fc5f7d0d92421ef20bfd0186bc (diff)
downloadrspamd-ddea9ac6acfa6bf3fb7aefa89c93ccf42cbe4c06.tar.gz
rspamd-ddea9ac6acfa6bf3fb7aefa89c93ccf42cbe4c06.zip
Add the parser of double fields.
Diffstat (limited to 'src')
-rw-r--r--src/cfg_rcl.c16
-rw-r--r--src/cfg_rcl.h17
2 files changed, 33 insertions, 0 deletions
diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c
index b59524cfb..942c944a6 100644
--- a/src/cfg_rcl.c
+++ b/src/cfg_rcl.c
@@ -342,3 +342,19 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
return TRUE;
}
+
+gboolean
+rspamd_rcl_parse_struct_double (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;
+ gdouble *target;
+
+ target = (gdouble *)(((gchar *)pd->user_struct) + pd->offset);
+
+ if (!rspamd_cl_obj_todouble_safe (obj, target)) {
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to double");
+ }
+
+ return TRUE;
+}
diff --git a/src/cfg_rcl.h b/src/cfg_rcl.h
index 7ee2a4fbb..93b9bba7d 100644
--- a/src/cfg_rcl.h
+++ b/src/cfg_rcl.h
@@ -92,6 +92,11 @@ struct rspamd_rcl_struct_parser {
gpointer user_struct;
goffset offset;
gsize size;
+#define RSPAMD_CL_FLAG_TIME_FLOAT 0x1 << 0
+#define RSPAMD_CL_FLAG_TIME_TIMEVAL 0x1 << 1
+#define RSPAMD_CL_FLAG_TIME_TIMESPEC 0x1 << 2
+#define RSPAMD_CL_FLAG_TIME_INTEGER 0x1 << 3
+ gint flags;
};
/**
@@ -119,4 +124,16 @@ gboolean rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_obj
gpointer ud, struct rspamd_rcl_section *section, GError **err);
+/**
+ * Parse a float 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 value has been successfully parsed
+ */
+gboolean rspamd_rcl_parse_struct_double (struct config_file *cfg, rspamd_cl_object_t *obj,
+ gpointer ud, struct rspamd_rcl_section *section, GError **err);
+
#endif /* CFG_RCL_H_ */