diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-30 14:58:41 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-30 14:58:41 +0100 |
commit | aaef1f83ddcc631b471f85cac1c7b815990ad8b9 (patch) | |
tree | c37b792a3ddce7b30c7ed68bf1d50952745c3722 /src/libserver/cfg_rcl.h | |
parent | 69d84ae579a7817e5fac0c64cab4fd3b3d6b1470 (diff) | |
download | rspamd-aaef1f83ddcc631b471f85cac1c7b815990ad8b9.tar.gz rspamd-aaef1f83ddcc631b471f85cac1c7b815990ad8b9.zip |
Make RCL parser more abstract.
Diffstat (limited to 'src/libserver/cfg_rcl.h')
-rw-r--r-- | src/libserver/cfg_rcl.h | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h index ca856a38d..df9aa35b6 100644 --- a/src/libserver/cfg_rcl.h +++ b/src/libserver/cfg_rcl.h @@ -26,6 +26,7 @@ #include "config.h" #include "ucl.h" +#include "mem_pool.h" #define CFG_RCL_ERROR cfg_rcl_error_quark () static inline GQuark @@ -64,7 +65,7 @@ struct rspamd_rcl_struct_parser { * @param err error object * @return TRUE if a section has been parsed */ -typedef gboolean (*rspamd_rcl_handler_t) (struct rspamd_config *cfg, +typedef gboolean (*rspamd_rcl_handler_t) (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, GError **err); @@ -73,8 +74,7 @@ typedef gboolean (*rspamd_rcl_handler_t) (struct rspamd_config *cfg, * @param cfg configuration * @param ud user data */ -typedef void (*rspamd_rcl_section_fin_t)(struct rspamd_config *cfg, - gpointer ud); +typedef void (*rspamd_rcl_section_fin_t)(rspamd_mempool_t *pool, gpointer ud); @@ -101,8 +101,9 @@ struct rspamd_rcl_section * rspamd_rcl_config_get_section ( * @param obj object to handle * @return TRUE if an object can be parsed */ -gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top, - struct rspamd_config *cfg, const ucl_object_t *obj, GError **err); +gboolean rspamd_rcl_parse (struct rspamd_rcl_section *top, + gpointer ptr, rspamd_mempool_t *pool, + const ucl_object_t *obj, GError **err); /** @@ -115,7 +116,7 @@ gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top, * @return TRUE if the object has been parsed */ gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section, - struct rspamd_config *cfg, const ucl_object_t *obj, gpointer ptr, + rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ptr, GError **err); /** * Here is a section of common handlers that accepts rcl_struct_parser @@ -132,7 +133,7 @@ gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section, * @param err error pointer * @return TRUE if a string value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_string (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_string (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -147,7 +148,7 @@ gboolean rspamd_rcl_parse_struct_string (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_integer (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_integer (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -163,7 +164,7 @@ gboolean rspamd_rcl_parse_struct_integer (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_double (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_double (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -178,7 +179,7 @@ gboolean rspamd_rcl_parse_struct_double (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_time (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_time (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -193,7 +194,7 @@ gboolean rspamd_rcl_parse_struct_time (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_string_list (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -208,7 +209,7 @@ gboolean rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_boolean (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_boolean (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, @@ -223,7 +224,22 @@ gboolean rspamd_rcl_parse_struct_boolean (struct rspamd_config *cfg, * @param err error pointer * @return TRUE if a value has been successfully parsed */ -gboolean rspamd_rcl_parse_struct_keypair (struct rspamd_config *cfg, +gboolean rspamd_rcl_parse_struct_keypair (rspamd_mempool_t *pool, + const ucl_object_t *obj, + gpointer ud, + struct rspamd_rcl_section *section, + GError **err); + +/** + * Parse a inet addr field of a structure + * @param cfg config pointer + * @param obj object to parse + * @param ud struct_parser structure (flags mean the exact structure used) + * @param section the current section + * @param err error pointer + * @return TRUE if a value has been successfully parsed + */ +gboolean rspamd_rcl_parse_struct_addr (rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ud, struct rspamd_rcl_section *section, |