diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-07-20 19:33:48 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-07-20 19:33:48 +0400 |
commit | f86068d197719b8758fc0a2aeb8556526b2331f8 (patch) | |
tree | 99f59e943f7437dc9987bb9b9d6a23d1e12df6a1 /src/map.h | |
parent | acc1e657ead019fd3e0835cadddf4d39a7b9f181 (diff) | |
download | rspamd-f86068d197719b8758fc0a2aeb8556526b2331f8.tar.gz rspamd-f86068d197719b8758fc0a2aeb8556526b2331f8.zip |
* Introduce new common system of map files, that can be used for different types of maps.
This includes new logic of callbacks and callbacks calling, files are monitored with
evtimers with jittering. HTTP support would be included soon as well.
Diffstat (limited to 'src/map.h')
-rw-r--r-- | src/map.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/map.h b/src/map.h new file mode 100644 index 000000000..dfd63a06d --- /dev/null +++ b/src/map.h @@ -0,0 +1,55 @@ +#ifndef RSPAMD_MAP_H +#define RSPAMD_MAP_H + +#include "config.h" +#include "mem_pool.h" +#include "radix.h" + +enum fetch_proto { + PROTO_FILE, + PROTO_HTTP, +}; + +struct map_cb_data { + int state; + void *prev_data; + void *cur_data; +}; + +struct file_map_data { + const char *filename; + struct stat st; +}; + +struct http_map_data { + struct in_addr addr; + uint16_t port; + char *path; + char *host; + time_t last_checked; +}; + +typedef void (*map_cb_t)(memory_pool_t *pool, u_char *chunk, size_t len, struct map_cb_data *data); +typedef void (*map_fin_cb_t)(memory_pool_t *pool, struct map_cb_data *data); + +struct rspamd_map { + memory_pool_t *pool; + enum fetch_proto protocol; + map_cb_t read_callback; + map_fin_cb_t fin_callback; + void **user_data; + struct event ev; + struct timeval tv; + void *map_data; +}; + +gboolean add_map (const char *map_line, map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data); +void start_map_watch (void); + +/* Common callbacks */ +void read_radix_list (memory_pool_t *pool, u_char *chunk, size_t len, struct map_cb_data *data); +void fin_radix_list (memory_pool_t *pool, struct map_cb_data *data); +void read_host_list (memory_pool_t *pool, u_char *chunk, size_t len, struct map_cb_data *data); +void fin_host_list (memory_pool_t *pool, struct map_cb_data *data); + +#endif |