diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-04 14:32:52 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-04 14:32:52 +0000 |
commit | 07933519f3925e439406b8ccc391540c2f0a3c1f (patch) | |
tree | d761efa5a1e7e2f852c05a76f2bb357230d87d34 /src/libserver/rspamd_symcache.h | |
parent | 253067d2b539cadb507ba43530f593f0a187ad91 (diff) | |
download | rspamd-07933519f3925e439406b8ccc391540c2f0a3c1f.tar.gz rspamd-07933519f3925e439406b8ccc391540c2f0a3c1f.zip |
[Minor] Add more flexible symcache item access functions
Diffstat (limited to 'src/libserver/rspamd_symcache.h')
-rw-r--r-- | src/libserver/rspamd_symcache.h | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/libserver/rspamd_symcache.h b/src/libserver/rspamd_symcache.h index 23d1a72ab..0eab043fd 100644 --- a/src/libserver/rspamd_symcache.h +++ b/src/libserver/rspamd_symcache.h @@ -68,6 +68,17 @@ struct rspamd_abstract_callback_data { char data[]; }; +struct rspamd_symcache_item_stat { + struct rspamd_counter_data time_counter; + gdouble avg_time; + gdouble weight; + guint hits; + guint64 total_hits; + struct rspamd_counter_data frequency_counter; + gdouble avg_frequency; + gdouble stddev_frequency; +}; + /** * Creates new cache structure * @return @@ -357,8 +368,7 @@ gboolean rspamd_symcache_disable_symbol (struct rspamd_task *task, * @param ud */ void rspamd_symcache_foreach (struct rspamd_symcache *cache, - void (*func) (gint /* id */, const gchar * /* name */, - gint /* flags */, gpointer /* userdata */), + void (*func) (struct rspamd_symcache_item *item, gpointer /* userdata */), gpointer ud); /** @@ -516,7 +526,48 @@ gboolean rspamd_symcache_is_item_allowed (struct rspamd_task *task, * @param item * @return */ -enum rspamd_symbol_type rspamd_symcache_item_flags (struct rspamd_symcache_item *item); +gint rspamd_symcache_item_flags (struct rspamd_symcache_item *item); +/** + * Returns cache item name + * @param item + * @return + */ +const gchar* rspamd_symcache_item_name (struct rspamd_symcache_item *item); +/** + * Returns the current item stat + * @param item + * @return + */ +const struct rspamd_symcache_item_stat * + rspamd_symcache_item_stat (struct rspamd_symcache_item *item); +/** + * Returns if an item is enabled (for virutal it also means that parent should be enabled) + * @param item + * @return + */ +gboolean rspamd_symcache_item_is_enabled (struct rspamd_symcache_item *item); +/** + * Returns parent for virtual symbols (or NULL) + * @param item + * @return + */ +struct rspamd_symcache_item * rspamd_symcache_item_get_parent ( + struct rspamd_symcache_item *item); +/** + * Returns direct deps for an element + * @param item + * @return array of struct rspamd_symcache_item * + */ +const GPtrArray* rspamd_symcache_item_get_deps ( + struct rspamd_symcache_item *item); +/** + * Returns direct reverse deps for an element + * @param item + * @return array of struct rspamd_symcache_item * + */ +const GPtrArray* rspamd_symcache_item_get_rdeps ( + struct rspamd_symcache_item *item); + #ifdef __cplusplus } |