aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-25 13:37:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-25 13:37:07 +0100
commitfcd60ee107f7529e50bb6eab4e92cd5de41b6bd0 (patch)
treeeef21331686a9f20c7a43ec670c8487a11d2d192
parent250388149c8d634d58a7d9996e560ebddcbe49aa (diff)
downloadrspamd-fcd60ee107f7529e50bb6eab4e92cd5de41b6bd0.tar.gz
rspamd-fcd60ee107f7529e50bb6eab4e92cd5de41b6bd0.zip
[Minor] Implement traverse functor in maps
-rw-r--r--src/libutil/map.c10
-rw-r--r--src/libutil/map.h12
-rw-r--r--src/libutil/map_private.h7
3 files changed, 26 insertions, 3 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 931e9b90e..0a27365eb 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -2222,3 +2222,13 @@ err:
return NULL;
}
+
+rspamd_map_traverse_function
+rspamd_map_get_traverse_function (struct rspamd_map *map)
+{
+ if (map) {
+ return map->traverse_function;
+ }
+
+ return NULL;
+} \ No newline at end of file
diff --git a/src/libutil/map.h b/src/libutil/map.h
index 171c0c55f..75c8788ca 100644
--- a/src/libutil/map.h
+++ b/src/libutil/map.h
@@ -23,6 +23,11 @@ typedef gchar * (*map_cb_t)(gchar *chunk, gint len,
struct map_cb_data *data, gboolean final);
typedef void (*map_fin_cb_t)(struct map_cb_data *data);
+typedef gboolean (*rspamd_map_traverse_cb)(gconstpointer key,
+ gconstpointer value, gsize hits, gpointer ud);
+typedef void (*rspamd_map_traverse_function)(rspamd_map_traverse_cb cb,
+ gpointer cbdata, gboolean reset_hits);
+
/**
* Common map object
*/
@@ -77,4 +82,11 @@ void rspamd_map_watch (struct rspamd_config *cfg, struct event_base *ev_base,
*/
void rspamd_map_remove_all (struct rspamd_config *cfg);
+/**
+ * Get traverse function for specific map
+ * @param map
+ * @return
+ */
+rspamd_map_traverse_function rspamd_map_get_traverse_function (struct rspamd_map *map);
+
#endif
diff --git a/src/libutil/map_private.h b/src/libutil/map_private.h
index 1de6fb942..fb1e609bd 100644
--- a/src/libutil/map_private.h
+++ b/src/libutil/map_private.h
@@ -114,18 +114,19 @@ struct rspamd_map {
gchar *name;
guint32 id;
gboolean scheduled_check;
+ rspamd_map_dtor dtor;
+ gpointer dtor_data;
+ rspamd_map_traverse_function traverse_function;
/* Should we check HTTP or just load cached data */
- gboolean active_http;
struct timeval tv;
gdouble poll_timeout;
time_t next_check;
+ gboolean active_http;
/* Shared lock for temporary disabling of map reading (e.g. when this map is written by UI) */
gint *locked;
/* Shared cache data */
struct rspamd_map_cachepoint *cache;
gchar tag[MEMPOOL_UID_LEN];
- rspamd_map_dtor dtor;
- gpointer dtor_data;
};
enum rspamd_map_http_stage {