return 1;
}
}
+ else if (strcmp (type, "regexp_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_regexp_list_read_multiple,
+ rspamd_regexp_list_fin,
+ (void **) &map->data.re_map)) == NULL) {
+ lua_pushnil (L);
+ ucl_object_unref (map_obj);
+
+ return 1;
+ }
+ }
else {
ret = luaL_error (L, "invalid arguments: unknown type '%s'", type);
ucl_object_unref (map_obj);
}
}
}
+ else if (map->type == RSPAMD_LUA_MAP_REGEXP_MULTIPLE) {
+ GPtrArray *ar;
+ guint i;
+ const gchar *val;
+
+ key = lua_map_process_string_key (L, 2, &len);
+
+ if (key && map->data.re_map) {
+ ar = rspamd_match_regexp_map_all (map->data.re_map, key,
+ len);
+
+ if (ar) {
+ lua_createtable (L, ar->len, 0);
+
+ PTR_ARRAY_FOREACH (ar, i, val) {
+ lua_pushstring (L, val);
+ lua_rawseti (L, -2, i + 1);
+ }
+
+ g_ptr_array_free (ar, TRUE);
+
+ return 1;
+ }
+ }
+ }
else if (map->type == RSPAMD_LUA_MAP_HASH) {
/* key-value map */
key = lua_map_process_string_key (L, 2, &len);