diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-09 20:53:52 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-09 20:53:52 +0100 |
commit | 3d0a1252f12c8d18b959e6cd3367733160d976a4 (patch) | |
tree | 1e5dfa2a1f761258478f3479ed729a3596ec2022 /src/lua/lua_classifier.c | |
parent | b35772a2873d610c563d208073ea4b29135d24b7 (diff) | |
download | rspamd-3d0a1252f12c8d18b959e6cd3367733160d976a4.tar.gz rspamd-3d0a1252f12c8d18b959e6cd3367733160d976a4.zip |
[Minor] Add method to get classifier options from Lua
Diffstat (limited to 'src/lua/lua_classifier.c')
-rw-r--r-- | src/lua/lua_classifier.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index 488a9d477..871433124 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -19,9 +19,11 @@ /* Classifier methods */ LUA_FUNCTION_DEF (classifier, get_statfiles); LUA_FUNCTION_DEF (classifier, get_statfile_by_label); +LUA_FUNCTION_DEF (classifier, get_param); static const struct luaL_reg classifierlib_m[] = { LUA_INTERFACE_DEF (classifier, get_statfiles), + LUA_INTERFACE_DEF (classifier, get_param), LUA_INTERFACE_DEF (classifier, get_statfile_by_label), {"__tostring", rspamd_lua_class_tostring}, {NULL, NULL} @@ -84,6 +86,29 @@ lua_classifier_get_statfiles (lua_State *L) return 1; } +static gint +lua_classifier_get_param (lua_State *L) +{ + struct rspamd_classifier_config *ccf = lua_check_classifier (L); + const gchar *param; + const ucl_object_t *value; + + param = luaL_checkstring (L, 2); + + if (ccf != NULL && param != NULL) { + value = ucl_object_lookup (ccf->opts, param); + + if (value != NULL) { + ucl_object_push_lua (L, value, true); + return 1; + } + } + + lua_pushnil (L); + + return 1; +} + /* Get statfile with specified label */ static gint lua_classifier_get_statfile_by_label (lua_State *L) |