]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add method to check hyperscan support to multipattern library
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 24 Feb 2020 16:34:14 +0000 (16:34 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 24 Feb 2020 16:34:14 +0000 (16:34 +0000)
src/lua/lua_trie.c

index a1b0de1189599d0282d20a006c07ed28d2a7c177..3941a5a8554e89a8ededbde743089fb398e53860 100644 (file)
@@ -39,6 +39,7 @@ trie:match('some big text', trie_callback)
 
 /* Suffix trie */
 LUA_FUNCTION_DEF (trie, create);
+LUA_FUNCTION_DEF (trie, has_hyperscan);
 LUA_FUNCTION_DEF (trie, match);
 LUA_FUNCTION_DEF (trie, search_mime);
 LUA_FUNCTION_DEF (trie, search_rawmsg);
@@ -56,6 +57,7 @@ static const struct luaL_reg trielib_m[] = {
 };
 static const struct luaL_reg trielib_f[] = {
        LUA_INTERFACE_DEF (trie, create),
+       LUA_INTERFACE_DEF (trie, has_hyperscan),
        {NULL, NULL}
 };
 
@@ -80,6 +82,19 @@ lua_trie_destroy (lua_State *L)
        return 0;
 }
 
+/***
+ * function trie.has_hyperscan()
+ * Checks for hyperscan support
+ *
+ * @return {bool} true if hyperscan is supported
+ */
+static gint
+lua_trie_has_hyperscan (lua_State *L)
+{
+       lua_pushboolean (L, rspamd_multipattern_has_hyperscan ());
+       return 1;
+}
+
 /***
  * function trie.create(patterns, [flags])
  * Creates new trie data structure