diff options
Diffstat (limited to 'src/libutil/map_helpers.h')
-rw-r--r-- | src/libutil/map_helpers.h | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/src/libutil/map_helpers.h b/src/libutil/map_helpers.h index 4645024e3..4f7b5b804 100644 --- a/src/libutil/map_helpers.h +++ b/src/libutil/map_helpers.h @@ -27,6 +27,11 @@ * Defines helper structures to deal with different map types */ + +#ifdef __cplusplus +extern "C" { +#endif + /** * Common structures, abstract for simplicity */ @@ -42,56 +47,64 @@ enum rspamd_regexp_map_flags { }; typedef void (*insert_func) (gpointer st, gconstpointer key, - gconstpointer value); + gconstpointer value); /** * Radix list is a list like ip/mask */ -gchar * rspamd_radix_read ( +gchar *rspamd_radix_read ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); + void rspamd_radix_fin (struct map_cb_data *data, void **target); + void rspamd_radix_dtor (struct map_cb_data *data); /** * Kv list is an ordinal list of keys and values separated by whitespace */ -gchar * rspamd_kv_list_read ( +gchar *rspamd_kv_list_read ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); + void rspamd_kv_list_fin (struct map_cb_data *data, void **target); + void rspamd_kv_list_dtor (struct map_cb_data *data); /** * Regexp list is a list of regular expressions */ -gchar * rspamd_regexp_list_read_single ( +gchar *rspamd_regexp_list_read_single ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); -gchar * rspamd_regexp_list_read_multiple ( + +gchar *rspamd_regexp_list_read_multiple ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); -gchar * rspamd_glob_list_read_single ( +gchar *rspamd_glob_list_read_single ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); -gchar * rspamd_glob_list_read_multiple ( + +gchar *rspamd_glob_list_read_multiple ( gchar *chunk, gint len, struct map_cb_data *data, gboolean final); + void rspamd_regexp_list_fin (struct map_cb_data *data, void **target); + void rspamd_regexp_list_dtor (struct map_cb_data *data); /** @@ -99,7 +112,7 @@ void rspamd_regexp_list_dtor (struct map_cb_data *data); */ gchar * rspamd_parse_kv_list ( - gchar * chunk, + gchar *chunk, gint len, struct map_cb_data *data, insert_func func, @@ -115,7 +128,7 @@ rspamd_parse_kv_list ( * @return */ gconstpointer rspamd_match_regexp_map_single (struct rspamd_regexp_map_helper *map, - const gchar *in, gsize len); + const gchar *in, gsize len); /** * Find a multiple (all) matching regexp for the specified text or NULL if @@ -125,8 +138,8 @@ gconstpointer rspamd_match_regexp_map_single (struct rspamd_regexp_map_helper *m * @param len * @return */ -GPtrArray* rspamd_match_regexp_map_all (struct rspamd_regexp_map_helper *map, - const gchar *in, gsize len); +GPtrArray *rspamd_match_regexp_map_all (struct rspamd_regexp_map_helper *map, + const gchar *in, gsize len); /** * Find value matching specific key in a hash map @@ -136,7 +149,7 @@ GPtrArray* rspamd_match_regexp_map_all (struct rspamd_regexp_map_helper *map, * @return */ gconstpointer rspamd_match_hash_map (struct rspamd_hash_map_helper *map, - const gchar *in); + const gchar *in); /** * Find value matching specific key in a hash map @@ -146,10 +159,10 @@ gconstpointer rspamd_match_hash_map (struct rspamd_hash_map_helper *map, * @return */ gconstpointer rspamd_match_radix_map (struct rspamd_radix_map_helper *map, - const guchar *in, gsize inlen); + const guchar *in, gsize inlen); gconstpointer rspamd_match_radix_map_addr (struct rspamd_radix_map_helper *map, - const rspamd_inet_addr_t *addr); + const rspamd_inet_addr_t *addr); /** * Creates radix map helper @@ -157,6 +170,7 @@ gconstpointer rspamd_match_radix_map_addr (struct rspamd_radix_map_helper *map, * @return */ struct rspamd_radix_map_helper *rspamd_map_helper_new_radix (struct rspamd_map *map); + /** * Inserts new value into radix map * @param st @@ -164,6 +178,7 @@ struct rspamd_radix_map_helper *rspamd_map_helper_new_radix (struct rspamd_map * * @param value */ void rspamd_map_helper_insert_radix (gpointer st, gconstpointer key, gconstpointer value); + /** * Inserts new value into radix map performing synchronous resolving * @param st @@ -171,7 +186,8 @@ void rspamd_map_helper_insert_radix (gpointer st, gconstpointer key, gconstpoint * @param value */ void rspamd_map_helper_insert_radix_resolve (gpointer st, gconstpointer key, - gconstpointer value); + gconstpointer value); + /** * Destroys radix map helper * @param r @@ -185,6 +201,7 @@ void rspamd_map_helper_destroy_radix (struct rspamd_radix_map_helper *r); * @return */ struct rspamd_hash_map_helper *rspamd_map_helper_new_hash (struct rspamd_map *map); + /** * Inserts a new value into a hash map * @param st @@ -192,6 +209,7 @@ struct rspamd_hash_map_helper *rspamd_map_helper_new_hash (struct rspamd_map *ma * @param value */ void rspamd_map_helper_insert_hash (gpointer st, gconstpointer key, gconstpointer value); + /** * Destroys hash map helper * @param r @@ -204,8 +222,9 @@ void rspamd_map_helper_destroy_hash (struct rspamd_hash_map_helper *r); * @param flags * @return */ -struct rspamd_regexp_map_helper * rspamd_map_helper_new_regexp (struct rspamd_map *map, - enum rspamd_regexp_map_flags flags); +struct rspamd_regexp_map_helper *rspamd_map_helper_new_regexp (struct rspamd_map *map, + enum rspamd_regexp_map_flags flags); + /** * Inserts a new regexp into regexp map * @param st @@ -213,10 +232,15 @@ struct rspamd_regexp_map_helper * rspamd_map_helper_new_regexp (struct rspamd_ma * @param value */ void rspamd_map_helper_insert_re (gpointer st, gconstpointer key, gconstpointer value); + /** * Destroy regexp map * @param re_map */ void rspamd_map_helper_destroy_regexp (struct rspamd_regexp_map_helper *re_map); +#ifdef __cplusplus +} +#endif + #endif |