From 50ec6ec314e224b9d94aec0ac185eaca122f5040 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 21 Feb 2017 13:37:03 +0000 Subject: [PATCH] [Minor] Remove obsoleted functions --- src/lua/lua_cfg_file.c | 90 ------------------------------------------ 1 file changed, 90 deletions(-) diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c index 5133a4882..acf7e32b1 100644 --- a/src/lua/lua_cfg_file.c +++ b/src/lua/lua_cfg_file.c @@ -201,93 +201,3 @@ rspamd_lua_post_load_config (struct rspamd_config *cfg) lua_settop (L, 0); } - -/* Handle lua dynamic config param */ -gboolean -rspamd_lua_handle_param (struct rspamd_task *task, - gchar *mname, - gchar *optname, - enum lua_var_type expected_type, - gpointer *res) -{ - /* xxx: Adopt this for rcl */ - - /* Option not found */ - *res = NULL; - return FALSE; -} - -#define FAKE_RES_VAR "rspamd_res" -gboolean -rspamd_lua_check_condition (struct rspamd_config *cfg, const gchar *condition) -{ - lua_State *L = cfg->lua_state; - gchar *hostbuf, *condbuf; - gsize hostlen; - gboolean res; -#ifdef HAVE_SYS_UTSNAME_H - struct utsname uts; -#endif - - /* Set some globals for condition */ - /* XXX: think what other variables can be useful */ - hostlen = sysconf (_SC_HOST_NAME_MAX) + 1; - hostbuf = alloca (hostlen); - gethostname (hostbuf, hostlen); - hostbuf[hostlen - 1] = '\0'; - - /* Hostname */ - lua_pushstring (L, hostbuf); - lua_setglobal (L, "hostname"); - /* Config file name */ - lua_pushstring (L, cfg->cfg_name); - lua_setglobal (L, "cfg_name"); - /* Check for uname */ -#ifdef HAVE_SYS_UTSNAME_H - uname (&uts); - lua_pushstring (L, uts.sysname); - lua_setglobal (L, "osname"); - lua_pushstring (L, uts.release); - lua_setglobal (L, "osrelease"); -#else - lua_pushstring (L, "unknown"); - lua_setglobal (L, "osname"); - lua_pushstring (L, ""); - lua_setglobal (L, "osrelease"); -#endif - - /* Rspamd paths */ - lua_newtable (L); - rspamd_lua_table_set (L, "confdir", RSPAMD_CONFDIR); - rspamd_lua_table_set (L, "rundir", RSPAMD_RUNDIR); - rspamd_lua_table_set (L, "dbdir", RSPAMD_DBDIR); - rspamd_lua_table_set (L, "logdir", RSPAMD_LOGDIR); - rspamd_lua_table_set (L, "pluginsdir", RSPAMD_PLUGINSDIR); - rspamd_lua_table_set (L, "prefix", RSPAMD_PREFIX); - lua_setglobal (L, "rspamd_paths"); - - /* Make fake string */ - hostlen = sizeof (FAKE_RES_VAR "=") + strlen (condition); - condbuf = g_malloc (hostlen); - rspamd_strlcpy (condbuf, FAKE_RES_VAR "=", sizeof (FAKE_RES_VAR "=")); - g_strlcat (condbuf, condition, hostlen); - /* Evaluate condition */ - if (luaL_dostring (L, condbuf) != 0) { - msg_err_config("eval of '%s' failed: '%s'", condition, lua_tostring (L, -1)); - g_free (condbuf); - return FALSE; - } - /* Get global variable res to get result */ - lua_getglobal (L, FAKE_RES_VAR); - if (!lua_isboolean (L, -1)) { - msg_err_config("bad string evaluated: %s, type: %s", condbuf, - lua_typename (L, lua_type (L, -1))); - g_free (condbuf); - return FALSE; - } - - res = lua_toboolean (L, -1); - g_free (condbuf); - - return res; -} -- 2.39.5