aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-14 16:55:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-14 16:55:36 +0100
commit4ce9dbece67d8497ea2b703d6e966aba71aceb18 (patch)
treef1e6edff93dfbc72f0db1991b80d0400b6ae3fef /src
parent0d4212eb6cf416c2c02a030195462993bdc84fea (diff)
downloadrspamd-4ce9dbece67d8497ea2b703d6e966aba71aceb18.tar.gz
rspamd-4ce9dbece67d8497ea2b703d6e966aba71aceb18.zip
[Minor] Add glob_multi map type
Diffstat (limited to 'src')
-rw-r--r--src/libutil/map_helpers.c25
-rw-r--r--src/libutil/map_helpers.h6
-rw-r--r--src/lua/lua_map.c17
3 files changed, 48 insertions, 0 deletions
diff --git a/src/libutil/map_helpers.c b/src/libutil/map_helpers.c
index c43c23277..bf18102d8 100644
--- a/src/libutil/map_helpers.c
+++ b/src/libutil/map_helpers.c
@@ -1027,6 +1027,30 @@ rspamd_regexp_list_read_multiple (
struct rspamd_regexp_map_helper *re_map;
if (data->cur_data == NULL) {
+ re_map = rspamd_map_helper_new_regexp (data->map,
+ RSPAMD_REGEXP_MAP_FLAG_GLOB|RSPAMD_REGEXP_MAP_FLAG_MULTIPLE);
+ data->cur_data = re_map;
+ }
+
+ return rspamd_parse_kv_list (
+ chunk,
+ len,
+ data,
+ rspamd_map_helper_insert_re,
+ hash_fill,
+ final);
+}
+
+gchar *
+rspamd_glob_list_read_multiple (
+ gchar *chunk,
+ gint len,
+ struct map_cb_data *data,
+ gboolean final)
+{
+ struct rspamd_regexp_map_helper *re_map;
+
+ if (data->cur_data == NULL) {
re_map = rspamd_map_helper_new_regexp (data->map, RSPAMD_REGEXP_MAP_FLAG_MULTIPLE);
data->cur_data = re_map;
}
@@ -1040,6 +1064,7 @@ rspamd_regexp_list_read_multiple (
final);
}
+
void
rspamd_regexp_list_fin (struct map_cb_data *data)
{
diff --git a/src/libutil/map_helpers.h b/src/libutil/map_helpers.h
index 28a5e336b..f7c86436f 100644
--- a/src/libutil/map_helpers.h
+++ b/src/libutil/map_helpers.h
@@ -80,11 +80,17 @@ gchar * rspamd_regexp_list_read_multiple (
gint len,
struct map_cb_data *data,
gboolean final);
+
gchar * rspamd_glob_list_read_single (
gchar *chunk,
gint len,
struct map_cb_data *data,
gboolean final);
+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 rspamd_regexp_list_dtor (struct map_cb_data *data);
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index 1621abf0d..9cf50f1a2 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -639,6 +639,23 @@ lua_config_add_map (lua_State *L)
}
m->lua_map = map;
}
+ else if (strcmp (type, "glob_multi") == 0) {
+ map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*map));
+ map->data.re_map = NULL;
+ map->type = RSPAMD_LUA_MAP_REGEXP_MULTIPLE;
+
+ if ((m = rspamd_map_add_from_ucl (cfg, map_obj, description,
+ rspamd_glob_list_read_multiple,
+ rspamd_regexp_list_fin,
+ rspamd_regexp_list_dtor,
+ (void **) &map->data.re_map)) == NULL) {
+ lua_pushnil (L);
+ ucl_object_unref (map_obj);
+
+ return 1;
+ }
+ m->lua_map = map;
+ }
else {
ret = luaL_error (L, "invalid arguments: unknown type '%s'", type);
ucl_object_unref (map_obj);