aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classifiers/bayes.c4
-rw-r--r--src/classifiers/winnow.c4
-rw-r--r--src/libserver/cfg_rcl.c2
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/libserver/task.c4
-rw-r--r--src/lua/lua_buffer.c12
-rw-r--r--src/lua/lua_cdb.c4
-rw-r--r--src/lua/lua_cfg_file.c18
-rw-r--r--src/lua/lua_classifier.c24
-rw-r--r--src/lua/lua_common.c50
-rw-r--r--src/lua/lua_common.h58
-rw-r--r--src/lua/lua_config.c38
-rw-r--r--src/lua/lua_dns.c12
-rw-r--r--src/lua/lua_http.c10
-rw-r--r--src/lua/lua_ip.c14
-rw-r--r--src/lua/lua_mempool.c20
-rw-r--r--src/lua/lua_message.c4
-rw-r--r--src/lua/lua_redis.c6
-rw-r--r--src/lua/lua_regexp.c6
-rw-r--r--src/lua/lua_rsa.c22
-rw-r--r--src/lua/lua_session.c12
-rw-r--r--src/lua/lua_task.c74
-rw-r--r--src/lua/lua_upstream.c14
-rw-r--r--src/lua/lua_xmlrpc.c2
-rw-r--r--src/lua_worker.c16
-rw-r--r--src/main.c10
-rw-r--r--src/plugins/regexp.c8
-rw-r--r--src/smtp.c2
-rw-r--r--src/worker.c2
29 files changed, 227 insertions, 227 deletions
diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c
index 8b148366d..bd001a8c3 100644
--- a/src/classifiers/bayes.c
+++ b/src/classifiers/bayes.c
@@ -251,7 +251,7 @@ bayes_classify (struct classifier_ctx * ctx,
}
}
- cur = call_classifier_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
+ cur = rspamd_lua_call_cls_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
if (cur) {
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_list_free, cur);
@@ -511,7 +511,7 @@ bayes_learn_spam (struct classifier_ctx * ctx,
}
}
- cur = call_classifier_pre_callbacks (ctx->cfg, task, TRUE, is_spam, L);
+ cur = rspamd_lua_call_cls_pre_callbacks (ctx->cfg, task, TRUE, is_spam, L);
if (cur) {
skip_labels = FALSE;
rspamd_mempool_add_destructor (task->task_pool,
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index d6f374f8f..25ff0b37d 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -260,7 +260,7 @@ winnow_classify (struct classifier_ctx *ctx,
}
}
- cur = call_classifier_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
+ cur = rspamd_lua_call_cls_pre_callbacks (ctx->cfg, task, FALSE, FALSE, L);
if (cur) {
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_list_free, cur);
@@ -302,7 +302,7 @@ winnow_classify (struct classifier_ctx *ctx,
if (sel != NULL) {
#ifdef WITH_LUA
- max = call_classifier_post_callbacks (ctx->cfg, task, max, L);
+ max = rspamd_lua_call_cls_post_callbacks (ctx->cfg, task, max, L);
#endif
#ifdef HAVE_TANHL
max = tanhl (max);
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index d8f70de07..8060ed29f 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -611,7 +611,7 @@ rspamd_rcl_set_lua_globals (struct rspamd_config *cfg, lua_State *L)
}
pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
- lua_setclass (L, "rspamd{config}", -1);
+ rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
lua_setglobal (L, "rspamd_config");
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 8084baea1..abe47826e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -562,7 +562,7 @@ rspamd_config_post_load (struct rspamd_config *cfg)
cfg->default_metric = def_metric;
/* Lua options */
- (void)lua_post_load_config (cfg);
+ (void)rspamd_lua_post_load_config (cfg);
init_dynamic_config (cfg);
}
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 59f015f1b..cc70afd97 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -230,7 +230,7 @@ rspamd_task_restore (void *arg)
/* Call post filters */
if (task->state == WAIT_POST_FILTER && !task->skip_extra_filters) {
- lua_call_post_filters (task);
+ rspamd_lua_call_post_filters (task);
}
task->s->wanna_die = TRUE;
}
@@ -354,7 +354,7 @@ rspamd_task_process (struct rspamd_task *task,
}
}
else {
- lua_call_pre_filters (task);
+ rspamd_lua_call_pre_filters (task);
/* We want fin_task after pre filters are processed */
task->s->wanna_die = TRUE;
task->state = WAIT_PRE_FILTER;
diff --git a/src/lua/lua_buffer.c b/src/lua/lua_buffer.c
index 4340a2b1f..97598e606 100644
--- a/src/lua/lua_buffer.c
+++ b/src/lua/lua_buffer.c
@@ -42,7 +42,7 @@ static const struct luaL_reg io_dispatcherlib_m[] = {
LUA_INTERFACE_DEF (io_dispatcher, pause),
LUA_INTERFACE_DEF (io_dispatcher, restore),
LUA_INTERFACE_DEF (io_dispatcher, destroy),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -89,7 +89,7 @@ lua_io_read_cb (f_str_t * in, void *arg)
lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_read);
pdispatcher =
lua_newuserdata (cbdata->L, sizeof (struct rspamd_io_dispatcher_s *));
- lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
+ rspamd_lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
*pdispatcher = cbdata->d;
lua_pushlstring (cbdata->L, in->begin, in->len);
@@ -117,7 +117,7 @@ lua_io_write_cb (void *arg)
pdispatcher =
lua_newuserdata (cbdata->L,
sizeof (struct rspamd_io_dispatcher_s *));
- lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
+ rspamd_lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
*pdispatcher = cbdata->d;
@@ -143,7 +143,7 @@ lua_io_err_cb (GError * err, void *arg)
lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_err);
pdispatcher =
lua_newuserdata (cbdata->L, sizeof (struct rspamd_io_dispatcher_s *));
- lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
+ rspamd_lua_setclass (cbdata->L, "rspamd{io_dispatcher}", -1);
*pdispatcher = cbdata->d;
lua_pushstring (cbdata->L, err->message);
@@ -224,7 +224,7 @@ lua_io_dispatcher_create (lua_State *L)
/* Push result */
pdispatcher =
lua_newuserdata (L, sizeof (struct rspamd_io_dispatcher_s *));
- lua_setclass (L, "rspamd{io_dispatcher}", -1);
+ rspamd_lua_setclass (L, "rspamd{io_dispatcher}", -1);
*pdispatcher = io_dispatcher;
}
else {
@@ -363,7 +363,7 @@ luaopen_io_dispatcher (lua_State * L)
lua_pop (L, 1); /* remove metatable from stack */
/* Simple event class */
- lua_newclass (L, "rspamd{ev_base}", null_reg);
+ rspamd_lua_new_class (L, "rspamd{ev_base}", null_reg);
luaL_register (L, "rspamd_ev_base", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c
index 0b0821dd0..2ede3c24c 100644
--- a/src/lua/lua_cdb.c
+++ b/src/lua/lua_cdb.c
@@ -34,7 +34,7 @@ LUA_FUNCTION_DEF (cdb, destroy);
static const struct luaL_reg cdblib_m[] = {
LUA_INTERFACE_DEF (cdb, lookup),
LUA_INTERFACE_DEF (cdb, get_name),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_cdb_destroy},
{NULL, NULL}
};
@@ -80,7 +80,7 @@ lua_cdb_create (lua_State *L)
}
else {
pcdb = lua_newuserdata (L, sizeof (struct cdb *));
- lua_setclass (L, "rspamd{cdb}", -1);
+ rspamd_lua_setclass (L, "rspamd{cdb}", -1);
*pcdb = cdb;
}
}
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index c17a85c6a..08f9e40db 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -131,7 +131,7 @@ lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
/* Do post load initialization based on lua */
void
-lua_post_load_config (struct rspamd_config *cfg)
+rspamd_lua_post_load_config (struct rspamd_config *cfg)
{
lua_State *L = cfg->lua_state;
const gchar *name, *val;
@@ -213,7 +213,7 @@ lua_post_load_config (struct rspamd_config *cfg)
/* Handle lua dynamic config param */
gboolean
-lua_handle_param (struct rspamd_task *task,
+rspamd_lua_handle_param (struct rspamd_task *task,
gchar *mname,
gchar *optname,
enum lua_var_type expected_type,
@@ -228,7 +228,7 @@ lua_handle_param (struct rspamd_task *task,
#define FAKE_RES_VAR "rspamd_res"
gboolean
-lua_check_condition (struct rspamd_config *cfg, const gchar *condition)
+rspamd_lua_check_condition (struct rspamd_config *cfg, const gchar *condition)
{
lua_State *L = cfg->lua_state;
gchar *hostbuf, *condbuf;
@@ -274,12 +274,12 @@ lua_check_condition (struct rspamd_config *cfg, const gchar *condition)
/* Rspamd paths */
lua_newtable (L);
- lua_set_table_index (L, "confdir", RSPAMD_CONFDIR);
- lua_set_table_index (L, "rundir", RSPAMD_RUNDIR);
- lua_set_table_index (L, "dbdir", RSPAMD_DBDIR);
- lua_set_table_index (L, "logdir", RSPAMD_LOGDIR);
- lua_set_table_index (L, "pluginsdir", RSPAMD_PLUGINSDIR);
- lua_set_table_index (L, "prefix", RSPAMD_PREFIX);
+ 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 */
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index ecd3cf9fc..869bca865 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -38,7 +38,7 @@ static const struct luaL_reg classifierlib_m[] = {
LUA_INTERFACE_DEF (classifier, register_post_callback),
LUA_INTERFACE_DEF (classifier, get_statfiles),
LUA_INTERFACE_DEF (classifier, get_statfile_by_label),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -57,7 +57,7 @@ static const struct luaL_reg statfilelib_m[] = {
LUA_INTERFACE_DEF (statfile, get_size),
LUA_INTERFACE_DEF (statfile, is_spam),
LUA_INTERFACE_DEF (statfile, get_param),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -92,11 +92,11 @@ call_classifier_pre_callback (struct rspamd_classifier_config *ccf,
GList *res = NULL;
pccf = lua_newuserdata (L, sizeof (struct rspamd_classifier_config *));
- lua_setclass (L, "rspamd{classifier}", -1);
+ rspamd_lua_setclass (L, "rspamd{classifier}", -1);
*pccf = ccf;
ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
lua_pushboolean (L, is_learn);
@@ -124,7 +124,7 @@ call_classifier_pre_callback (struct rspamd_classifier_config *ccf,
/* Return list of statfiles that should be checked for this message */
GList *
-call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf,
+rspamd_lua_call_cls_pre_callbacks (struct rspamd_classifier_config *ccf,
struct rspamd_task *task,
gboolean is_learn,
gboolean is_spam,
@@ -171,7 +171,7 @@ call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf,
/* Return result mark for statfile */
double
-call_classifier_post_callbacks (struct rspamd_classifier_config *ccf,
+rspamd_lua_call_cls_post_callbacks (struct rspamd_classifier_config *ccf,
struct rspamd_task *task,
double in,
lua_State *L)
@@ -189,11 +189,11 @@ call_classifier_post_callbacks (struct rspamd_classifier_config *ccf,
lua_getglobal (L, cd->name);
pccf = lua_newuserdata (L, sizeof (struct rspamd_classifier_config *));
- lua_setclass (L, "rspamd{classifier}", -1);
+ rspamd_lua_setclass (L, "rspamd{classifier}", -1);
*pccf = ccf;
ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
lua_pushnumber (L, out);
@@ -273,7 +273,7 @@ lua_classifier_get_statfiles (lua_State *L)
while (cur) {
st = cur->data;
pst = lua_newuserdata (L, sizeof (struct rspamd_statfile_config *));
- lua_setclass (L, "rspamd{statfile}", -1);
+ rspamd_lua_setclass (L, "rspamd{statfile}", -1);
*pst = st;
lua_rawseti (L, -2, i++);
@@ -308,7 +308,7 @@ lua_classifier_get_statfile_by_label (lua_State *L)
pst =
lua_newuserdata (L,
sizeof (struct rspamd_statfile_config *));
- lua_setclass (L, "rspamd{statfile}", -1);
+ rspamd_lua_setclass (L, "rspamd{statfile}", -1);
*pst = st;
lua_rawseti (L, -2, i++);
cur = g_list_next (cur);
@@ -431,7 +431,7 @@ lua_check_statfile (lua_State * L)
gint
luaopen_classifier (lua_State * L)
{
- lua_newclass (L, "rspamd{classifier}", classifierlib_m);
+ rspamd_lua_new_class (L, "rspamd{classifier}", classifierlib_m);
luaL_register (L, "rspamd_classifier", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -442,7 +442,7 @@ luaopen_classifier (lua_State * L)
gint
luaopen_statfile (lua_State * L)
{
- lua_newclass (L, "rspamd{statfile}", statfilelib_m);
+ rspamd_lua_new_class (L, "rspamd{statfile}", statfilelib_m);
luaL_register (L, "rspamd_statfile", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 6600bfc35..0d68a364e 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -29,7 +29,7 @@
#define MODULE_INIT_FUNC "module_init"
const luaL_reg null_reg[] = {
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -44,7 +44,7 @@ static const struct luaL_reg loggerlib_f[] = {
LUA_INTERFACE_DEF (logger, warn),
LUA_INTERFACE_DEF (logger, info),
LUA_INTERFACE_DEF (logger, debug),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -57,7 +57,7 @@ static const struct luaL_reg loggerlib_f[] = {
* @param func table of class methods
*/
void
-lua_newclass (lua_State * L,
+rspamd_lua_new_class (lua_State * L,
const gchar *classname,
const struct luaL_reg *methods)
{
@@ -76,18 +76,18 @@ lua_newclass (lua_State * L,
* Create and register new class with static methods and store metatable on top of the stack
*/
void
-lua_newclass_full (lua_State *L,
+rspamd_lua_new_class_full (lua_State *L,
const gchar *classname,
const gchar *static_name,
const struct luaL_reg *methods,
const struct luaL_reg *func)
{
- lua_newclass (L, classname, methods);
+ rspamd_lua_new_class (L, classname, methods);
luaL_register (L, static_name, func);
}
gint
-lua_class_tostring (lua_State * L)
+rspamd_lua_class_tostring (lua_State * L)
{
gchar buf[32];
@@ -121,7 +121,7 @@ error:
void
-lua_setclass (lua_State * L, const gchar *classname, gint objidx)
+rspamd_lua_setclass (lua_State * L, const gchar *classname, gint objidx)
{
luaL_getmetatable (L, classname);
if (objidx < 0) {
@@ -132,7 +132,7 @@ lua_setclass (lua_State * L, const gchar *classname, gint objidx)
/* assume that table is at the top */
void
-lua_set_table_index (lua_State * L, const gchar *index, const gchar *value)
+rspamd_lua_table_set (lua_State * L, const gchar *index, const gchar *value)
{
lua_pushstring (L, index);
@@ -146,7 +146,7 @@ lua_set_table_index (lua_State * L, const gchar *index, const gchar *value)
}
const gchar *
-lua_get_table_index_str (lua_State *L, const gchar *index)
+rspamd_lua_table_get (lua_State *L, const gchar *index)
{
const gchar *result;
@@ -287,7 +287,7 @@ lua_add_actions_global (lua_State *L)
}
lua_State *
-init_lua (struct rspamd_config *cfg)
+rspamd_lua_init (struct rspamd_config *cfg)
{
lua_State *L;
@@ -330,12 +330,12 @@ init_lua (struct rspamd_config *cfg)
* Initialize new locked lua_State structure
*/
struct lua_locked_state *
-init_lua_locked (struct rspamd_config *cfg)
+rspamd_init_lua_locked (struct rspamd_config *cfg)
{
struct lua_locked_state *new;
new = g_slice_alloc (sizeof (struct lua_locked_state));
- new->L = init_lua (cfg);
+ new->L = rspamd_lua_init (cfg);
new->m = rspamd_mutex_new ();
return new;
@@ -346,7 +346,7 @@ init_lua_locked (struct rspamd_config *cfg)
* Free locked state structure
*/
void
-free_lua_locked (struct lua_locked_state *st)
+rspamd_free_lua_locked (struct lua_locked_state *st)
{
g_assert (st != NULL);
@@ -358,7 +358,7 @@ free_lua_locked (struct lua_locked_state *st)
}
gboolean
-init_lua_filters (struct rspamd_config *cfg)
+rspamd_init_lua_filters (struct rspamd_config *cfg)
{
struct rspamd_config **pcfg;
GList *cur, *tmp;
@@ -379,7 +379,7 @@ init_lua_filters (struct rspamd_config *cfg)
/* Initialize config structure */
pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
- lua_setclass (L, "rspamd{config}", -1);
+ rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
lua_setglobal (L, "rspamd_config");
@@ -405,7 +405,7 @@ init_lua_filters (struct rspamd_config *cfg)
cur = g_list_first (cfg->statfiles);
while (cur) {
st = cur->data;
- if (st->normalizer == lua_normalizer_func) {
+ if (st->normalizer == rspamd_lua_normalize) {
tmp = st->normalizer_data;
if (tmp && (tmp = g_list_next (tmp))) {
if (tmp->data) {
@@ -428,7 +428,7 @@ init_lua_filters (struct rspamd_config *cfg)
/* Callback functions */
gint
-lua_call_filter (const gchar *function, struct rspamd_task *task)
+rspamd_lua_call_filter (const gchar *function, struct rspamd_task *task)
{
gint result;
struct rspamd_task **ptask;
@@ -436,7 +436,7 @@ lua_call_filter (const gchar *function, struct rspamd_task *task)
lua_getglobal (L, function);
ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
if (lua_pcall (L, 1, 1, 0) != 0) {
@@ -454,7 +454,7 @@ lua_call_filter (const gchar *function, struct rspamd_task *task)
}
gint
-lua_call_chain_filter (const gchar *function,
+rspamd_lua_call_chain_filter (const gchar *function,
struct rspamd_task *task,
gint *marks,
guint number)
@@ -484,7 +484,7 @@ lua_call_chain_filter (const gchar *function,
/* Call custom lua function in rspamd expression */
gboolean
-lua_call_expression_func (gpointer lua_data,
+rspamd_lua_call_expression_func (gpointer lua_data,
struct rspamd_task *task, GList *args, gboolean *res)
{
lua_State *L = task->cfg->lua_state;
@@ -496,7 +496,7 @@ lua_call_expression_func (gpointer lua_data,
lua_rawgeti (L, LUA_REGISTRYINDEX, GPOINTER_TO_INT (lua_data));
/* Now we got function in top of stack */
ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
/* Now push all arguments */
@@ -574,7 +574,7 @@ lua_consolidation_callback (gpointer key, gpointer value, gpointer arg)
}
double
-lua_consolidation_func (struct rspamd_task *task,
+rspamd_lua_consolidation_func (struct rspamd_task *task,
const gchar *metric_name,
const gchar *function_name)
{
@@ -598,7 +598,7 @@ lua_consolidation_func (struct rspamd_task *task,
}
double
-lua_normalizer_func (struct rspamd_config *cfg, long double score, void *params)
+rspamd_lua_normalize (struct rspamd_config *cfg, long double score, void *params)
{
GList *p = params;
long double res = score;
@@ -629,7 +629,7 @@ lua_normalizer_func (struct rspamd_config *cfg, long double score, void *params)
void
-lua_dumpstack (lua_State *L)
+rspamd_lua_dumpstack (lua_State *L)
{
gint i, t, r = 0;
gint top = lua_gettop (L);
@@ -675,7 +675,7 @@ lua_dumpstack (lua_State *L)
}
gpointer
-lua_check_class (lua_State *L, gint index, const gchar *name)
+rspamd_lua_check_class (lua_State *L, gint index, const gchar *name)
{
gpointer p;
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index a9f0d399a..78bf80fdb 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -60,14 +60,14 @@ struct lua_locked_state {
/**
* Create and register new class
*/
-void lua_newclass (lua_State *L,
+void rspamd_lua_new_class (lua_State *L,
const gchar *classname,
const struct luaL_reg *methods);
/**
* Create and register new class with static methods
*/
-void lua_newclass_full (lua_State *L,
+void rspamd_lua_new_class_full (lua_State *L,
const gchar *classname,
const gchar *static_name,
const struct luaL_reg *methods,
@@ -76,56 +76,56 @@ void lua_newclass_full (lua_State *L,
/**
* Set class name for object at @param objidx position
*/
-void lua_setclass (lua_State *L, const gchar *classname, gint objidx);
+void rspamd_lua_setclass (lua_State *L, const gchar *classname, gint objidx);
/**
* Set index of table to value (like t['index'] = value)
*/
-void lua_set_table_index (lua_State *L, const gchar *index, const gchar *value);
+void rspamd_lua_table_set (lua_State *L, const gchar *index, const gchar *value);
/**
* Get string value of index in a table (return t['index'])
*/
-const gchar * lua_get_table_index_str (lua_State *L, const gchar *index);
+const gchar * rspamd_lua_table_get (lua_State *L, const gchar *index);
/**
* Convert classname to string
*/
-gint lua_class_tostring (lua_State *L);
+gint rspamd_lua_class_tostring (lua_State *L);
/**
* Check whether the argument at specified index is of the specified class
*/
-gpointer lua_check_class (lua_State *L, gint index, const gchar *name);
+gpointer rspamd_lua_check_class (lua_State *L, gint index, const gchar *name);
/**
* Initialize lua and bindings
*/
-lua_State * init_lua (struct rspamd_config *cfg);
+lua_State * rspamd_lua_init (struct rspamd_config *cfg);
/**
* Load and initialize lua plugins
*/
-gboolean init_lua_filters (struct rspamd_config *cfg);
+gboolean rspamd_init_lua_filters (struct rspamd_config *cfg);
/**
* Initialize new locked lua_State structure
*/
-struct lua_locked_state * init_lua_locked (struct rspamd_config *cfg);
+struct lua_locked_state * rspamd_init_lua_locked (struct rspamd_config *cfg);
/**
* Free locked state structure
*/
-void free_lua_locked (struct lua_locked_state *st);
+void rspamd_free_lua_locked (struct lua_locked_state *st);
/**
* Push lua ip address
*/
-void lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr);
+void rspamd_lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr);
/**
* Push ip address from a string (nil is pushed if a string cannot be converted)
*/
-void lua_ip_push_fromstring (lua_State *L, const gchar *ip_str);
+void rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str);
/**
* Create type error
@@ -169,55 +169,55 @@ gint luaopen_dns_resolver (lua_State * L);
gint luaopen_rsa (lua_State * L);
gint luaopen_ip (lua_State * L);
-gint lua_call_filter (const gchar *function, struct rspamd_task *task);
-gint lua_call_chain_filter (const gchar *function,
+gint rspamd_lua_call_filter (const gchar *function, struct rspamd_task *task);
+gint rspamd_lua_call_chain_filter (const gchar *function,
struct rspamd_task *task,
gint *marks,
guint number);
-double lua_consolidation_func (struct rspamd_task *task,
+double rspamd_lua_consolidation_func (struct rspamd_task *task,
const gchar *metric_name,
const gchar *function_name);
-gboolean lua_call_expression_func (gpointer lua_data,
+gboolean rspamd_lua_call_expression_func (gpointer lua_data,
struct rspamd_task *task,
GList *args,
gboolean *res);
-void lua_call_post_filters (struct rspamd_task *task);
-void lua_call_pre_filters (struct rspamd_task *task);
-void add_luabuf (const gchar *line);
+void rspamd_lua_call_post_filters (struct rspamd_task *task);
+void rspamd_lua_call_pre_filters (struct rspamd_task *task);
+void rspamd_lua_dostring (const gchar *line);
/* Classify functions */
-GList * call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf,
+GList * rspamd_lua_call_cls_pre_callbacks (struct rspamd_classifier_config *ccf,
struct rspamd_task *task,
gboolean is_learn,
gboolean is_spam,
lua_State *L);
-double call_classifier_post_callbacks (struct rspamd_classifier_config *ccf,
+double rspamd_lua_call_cls_post_callbacks (struct rspamd_classifier_config *ccf,
struct rspamd_task *task,
double in,
lua_State *L);
-double lua_normalizer_func (struct rspamd_config *cfg,
+double rspamd_lua_normalize (struct rspamd_config *cfg,
long double score,
void *params);
/* Config file functions */
-void lua_post_load_config (struct rspamd_config *cfg);
-void lua_process_element (struct rspamd_config *cfg,
+void rspamd_lua_post_load_config (struct rspamd_config *cfg);
+void rspamd_lua_process_elt (struct rspamd_config *cfg,
const gchar *name,
const gchar *module_name,
struct rspamd_module_opt *opt,
gint idx,
gboolean allow_meta);
-gboolean lua_handle_param (struct rspamd_task *task,
+gboolean rspamd_lua_handle_param (struct rspamd_task *task,
gchar *mname,
gchar *optname,
enum lua_var_type expected_type,
gpointer *res);
-gboolean lua_check_condition (struct rspamd_config *cfg,
+gboolean rspamd_lua_check_condition (struct rspamd_config *cfg,
const gchar *condition);
-void lua_dumpstack (lua_State *L);
+void rspamd_lua_dumpstack (lua_State *L);
-struct memory_pool_s * lua_check_mempool (lua_State * L);
+struct memory_pool_s * rspamd_lua_check_mempool (lua_State * L);
#endif /* WITH_LUA */
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 57c1031c5..d8ef67f76 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -72,7 +72,7 @@ static const struct luaL_reg configlib_m[] = {
LUA_INTERFACE_DEF (config, register_post_filter),
LUA_INTERFACE_DEF (config, get_api_version),
LUA_INTERFACE_DEF (config, get_key),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -82,7 +82,7 @@ LUA_FUNCTION_DEF (radix, get_key);
static const struct luaL_reg radixlib_m[] = {
LUA_INTERFACE_DEF (radix, get_key),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -91,7 +91,7 @@ LUA_FUNCTION_DEF (hash_table, get_key);
static const struct luaL_reg hashlib_m[] = {
LUA_INTERFACE_DEF (hash_table, get_key),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -105,7 +105,7 @@ static const struct luaL_reg trielib_m[] = {
LUA_INTERFACE_DEF (trie, add_pattern),
LUA_INTERFACE_DEF (trie, search_text),
LUA_INTERFACE_DEF (trie, search_task),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
static const struct luaL_reg trielib_f[] = {
@@ -184,7 +184,7 @@ lua_config_get_mempool (lua_State * L)
if (cfg != NULL) {
ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *));
- lua_setclass (L, "rspamd{mempool}", -1);
+ rspamd_lua_setclass (L, "rspamd{mempool}", -1);
*ppool = cfg->cfg_pool;
}
return 1;
@@ -235,7 +235,7 @@ lua_config_get_classifier (lua_State * L)
if (pclc) {
pclc = lua_newuserdata (L,
sizeof (struct rspamd_classifier_config *));
- lua_setclass (L, "rspamd{classifier}", -1);
+ rspamd_lua_setclass (L, "rspamd{classifier}", -1);
*pclc = clc;
return 1;
}
@@ -289,7 +289,7 @@ lua_config_function_callback (struct rspamd_task *task,
lua_getglobal (cd->L, cd->callback.name);
}
ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
- lua_setclass (cd->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
/* Now push all arguments */
cur = args;
@@ -361,7 +361,7 @@ lua_config_register_module_option (lua_State *L)
}
void
-lua_call_post_filters (struct rspamd_task *task)
+rspamd_lua_call_post_filters (struct rspamd_task *task)
{
struct lua_callback_data *cd;
struct rspamd_task **ptask;
@@ -377,7 +377,7 @@ lua_call_post_filters (struct rspamd_task *task)
lua_getglobal (cd->L, cd->callback.name);
}
ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
- lua_setclass (cd->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
if (lua_pcall (cd->L, 1, 0, 0) != 0) {
@@ -421,7 +421,7 @@ lua_config_register_post_filter (lua_State *L)
}
void
-lua_call_pre_filters (struct rspamd_task *task)
+rspamd_lua_call_pre_filters (struct rspamd_task *task)
{
struct lua_callback_data *cd;
struct rspamd_task **ptask;
@@ -437,7 +437,7 @@ lua_call_pre_filters (struct rspamd_task *task)
lua_getglobal (cd->L, cd->callback.name);
}
ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
- lua_setclass (cd->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
if (lua_pcall (cd->L, 1, 0, 0) != 0) {
@@ -501,7 +501,7 @@ lua_config_add_radix_map (lua_State *L)
}
ud = lua_newuserdata (L, sizeof (radix_tree_t *));
*ud = r;
- lua_setclass (L, "rspamd{radix}", -1);
+ rspamd_lua_setclass (L, "rspamd{radix}", -1);
return 1;
}
@@ -535,7 +535,7 @@ lua_config_add_hash_map (lua_State *L)
*r);
ud = lua_newuserdata (L, sizeof (GHashTable *));
*ud = r;
- lua_setclass (L, "rspamd{hash_table}", -1);
+ rspamd_lua_setclass (L, "rspamd{hash_table}", -1);
return 1;
}
@@ -569,7 +569,7 @@ lua_config_add_kv_map (lua_State *L)
*r);
ud = lua_newuserdata (L, sizeof (GHashTable *));
*ud = r;
- lua_setclass (L, "rspamd{hash_table}", -1);
+ rspamd_lua_setclass (L, "rspamd{hash_table}", -1);
return 1;
}
@@ -726,7 +726,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
lua_getglobal (cd->L, cd->callback.name);
}
ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
- lua_setclass (cd->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
if (lua_pcall (cd->L, 1, 0, 0) != 0) {
@@ -988,7 +988,7 @@ lua_trie_create (lua_State *L)
trie = rspamd_trie_create (icase);
ptrie = lua_newuserdata (L, sizeof (rspamd_trie_t *));
- lua_setclass (L, "rspamd{trie}", -1);
+ rspamd_lua_setclass (L, "rspamd{trie}", -1);
*ptrie = trie;
return 1;
@@ -1107,7 +1107,7 @@ lua_trie_search_task (lua_State *L)
gint
luaopen_config (lua_State * L)
{
- lua_newclass (L, "rspamd{config}", configlib_m);
+ rspamd_lua_new_class (L, "rspamd{config}", configlib_m);
luaL_register (L, "rspamd_config", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1118,7 +1118,7 @@ luaopen_config (lua_State * L)
gint
luaopen_radix (lua_State * L)
{
- lua_newclass (L, "rspamd{radix}", radixlib_m);
+ rspamd_lua_new_class (L, "rspamd{radix}", radixlib_m);
luaL_register (L, "rspamd_radix", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1129,7 +1129,7 @@ luaopen_radix (lua_State * L)
gint
luaopen_hash_table (lua_State * L)
{
- lua_newclass (L, "rspamd{hash_table}", hashlib_m);
+ rspamd_lua_new_class (L, "rspamd{hash_table}", hashlib_m);
luaL_register (L, "rspamd_hash_table", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index e0930a2aa..fd3037b70 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -47,7 +47,7 @@ static const struct luaL_reg dns_resolverlib_m[] = {
LUA_INTERFACE_DEF (dns_resolver, resolve_txt),
LUA_INTERFACE_DEF (dns_resolver, resolve_mx),
LUA_INTERFACE_DEF (dns_resolver, resolve),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -94,7 +94,7 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
lua_rawgeti (cd->L, LUA_REGISTRYINDEX, cd->cbref);
presolver = lua_newuserdata (cd->L, sizeof (gpointer));
- lua_setclass (cd->L, "rspamd{resolver}", -1);
+ rspamd_lua_setclass (cd->L, "rspamd{resolver}", -1);
*presolver = cd->resolver;
lua_pushstring (cd->L, cd->to_resolve);
@@ -112,7 +112,7 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
addr.slen = sizeof (addr.addr.s4);
memcpy (&addr.addr.s4.sin_addr, &elt->content.a.addr,
sizeof (addr.addr.s4.sin_addr));
- lua_ip_push (cd->L, &addr);
+ rspamd_lua_ip_push (cd->L, &addr);
lua_rawseti (cd->L, -2, ++i);
break;
case RDNS_REQUEST_AAAA:
@@ -120,7 +120,7 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
addr.slen = sizeof (addr.addr.s6);
memcpy (&addr.addr.s6.sin6_addr, &elt->content.aaa.addr,
sizeof (addr.addr.s6.sin6_addr));
- lua_ip_push (cd->L, &addr);
+ rspamd_lua_ip_push (cd->L, &addr);
lua_rawseti (cd->L, -2, ++i);
break;
case RDNS_REQUEST_PTR:
@@ -135,7 +135,7 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
case RDNS_REQUEST_MX:
/* mx['name'], mx['priority'] */
lua_newtable (cd->L);
- lua_set_table_index (cd->L, "name", elt->content.mx.name);
+ rspamd_lua_table_set (cd->L, "name", elt->content.mx.name);
lua_pushstring (cd->L, "priority");
lua_pushnumber (cd->L, elt->content.mx.priority);
lua_settable (cd->L, -3);
@@ -185,7 +185,7 @@ lua_dns_resolver_init (lua_State *L)
resolver = dns_resolver_init (rspamd_main->logger, base, cfg);
if (resolver) {
presolver = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{resolver}", -1);
+ rspamd_lua_setclass (L, "rspamd{resolver}", -1);
*presolver = resolver;
}
else {
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 3ab057aee..8e6617ced 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -34,7 +34,7 @@ LUA_FUNCTION_DEF (http, make_get_request);
static const struct luaL_reg httplib_m[] = {
LUA_INTERFACE_DEF (http, make_post_request),
LUA_INTERFACE_DEF (http, make_get_request),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -88,7 +88,7 @@ lua_http_push_error (gint code, struct lua_http_ud *ud)
if (ud->callback) {
lua_getglobal (ud->L, ud->callback);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
- lua_setclass (ud->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (ud->L, "rspamd{task}", -1);
*ptask = ud->task;
num = 4;
}
@@ -131,7 +131,7 @@ lua_http_push_reply (f_str_t *in, struct lua_http_ud *ud)
/* Push error */
lua_getglobal (ud->L, ud->callback);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
- lua_setclass (ud->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (ud->L, "rspamd{task}", -1);
*ptask = ud->task;
num = 4;
@@ -582,7 +582,7 @@ lua_http_make_post_request (lua_State *L)
/* Check whether we have a task object */
- ptask = lua_check_class (L, 1, "rspamd{task}");
+ ptask = rspamd_lua_check_class (L, 1, "rspamd{task}");
task = ptask ? *(ptask) : NULL;
if (!task) {
@@ -661,7 +661,7 @@ lua_http_make_get_request (lua_State *L)
/* Check whether we have a task object */
- ptask = lua_check_class (L, 1, "rspamd{task}");
+ ptask = rspamd_lua_check_class (L, 1, "rspamd{task}");
task = ptask ? *(ptask) : NULL;
if (!task) {
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c
index 3292d93e7..7dc94e582 100644
--- a/src/lua/lua_ip.c
+++ b/src/lua/lua_ip.c
@@ -209,7 +209,7 @@ lua_ip_from_string (lua_State *L)
ip = g_slice_alloc (sizeof (struct rspamd_lua_ip));
ip->is_valid = rspamd_parse_inet_address (&ip->addr, ip_str);
pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
- lua_setclass (L, "rspamd{ip}", -1);
+ rspamd_lua_setclass (L, "rspamd{ip}", -1);
*pip = ip;
}
else {
@@ -262,7 +262,7 @@ lua_ip_from_number (lua_State *L)
ip->is_valid = TRUE;
ip->addr.addr.s4.sin_addr.s_addr = htonl (src[0]);
pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
- lua_setclass (L, "rspamd{ip}", -1);
+ rspamd_lua_setclass (L, "rspamd{ip}", -1);
*pip = ip;
}
else if (lua_gettop (L) == 4 && lua_isnumber (L, 1)) {
@@ -276,7 +276,7 @@ lua_ip_from_number (lua_State *L)
ip->is_valid = TRUE;
memcpy (&ip->addr.addr.s6.sin6_addr, src, sizeof (src));
pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
- lua_setclass (L, "rspamd{ip}", -1);
+ rspamd_lua_setclass (L, "rspamd{ip}", -1);
*pip = ip;
}
else {
@@ -329,7 +329,7 @@ lua_ip_is_valid (lua_State *L)
}
void
-lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr)
+rspamd_lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr)
{
struct rspamd_lua_ip *ip, **pip;
@@ -343,12 +343,12 @@ lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr)
memcpy (&ip->addr, addr, sizeof (ip->addr));
}
pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
- lua_setclass (L, "rspamd{ip}", -1);
+ rspamd_lua_setclass (L, "rspamd{ip}", -1);
*pip = ip;
}
void
-lua_ip_push_fromstring (lua_State *L, const gchar *ip_str)
+rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str)
{
struct rspamd_lua_ip *ip, **pip;
@@ -360,7 +360,7 @@ lua_ip_push_fromstring (lua_State *L, const gchar *ip_str)
ip->is_valid = rspamd_parse_inet_address (&ip->addr, ip_str);
pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
- lua_setclass (L, "rspamd{ip}", -1);
+ rspamd_lua_setclass (L, "rspamd{ip}", -1);
*pip = ip;
}
}
diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c
index 50de17dd1..465378af9 100644
--- a/src/lua/lua_mempool.c
+++ b/src/lua/lua_mempool.c
@@ -25,7 +25,7 @@
#include "mem_pool.h"
/* Public prototypes */
-struct memory_pool_s * lua_check_mempool (lua_State * L);
+struct memory_pool_s * rspamd_lua_check_mempool (lua_State * L);
gint luaopen_mempool (lua_State * L);
/* Lua bindings */
@@ -44,7 +44,7 @@ static const struct luaL_reg mempoollib_m[] = {
LUA_INTERFACE_DEF (mempool, memory_pool_set_variable),
LUA_INTERFACE_DEF (mempool, memory_pool_get_variable),
{"destroy", lua_mempool_memory_pool_delete},
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -64,7 +64,7 @@ struct lua_mempool_udata {
};
struct memory_pool_s *
-lua_check_mempool (lua_State * L)
+rspamd_lua_check_mempool (lua_State * L)
{
void *ud = luaL_checkudata (L, 1, "rspamd{mempool}");
luaL_argcheck (L, ud != NULL, 1, "'mempool' expected");
@@ -80,7 +80,7 @@ lua_mempool_create (lua_State *L)
if (mempool) {
pmempool = lua_newuserdata (L, sizeof (struct memory_pool_s *));
- lua_setclass (L, "rspamd{mempool}", -1);
+ rspamd_lua_setclass (L, "rspamd{mempool}", -1);
*pmempool = mempool;
}
else {
@@ -105,7 +105,7 @@ lua_mempool_destructor_func (gpointer p)
static int
lua_mempool_memory_pool_add_destructor (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
struct lua_mempool_udata *ud;
if (mempool) {
@@ -135,7 +135,7 @@ lua_mempool_memory_pool_add_destructor (lua_State *L)
static int
lua_mempool_memory_pool_delete (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
if (mempool) {
rspamd_mempool_delete (mempool);
@@ -151,7 +151,7 @@ lua_mempool_memory_pool_delete (lua_State *L)
static int
lua_mempool_memory_pool_stat (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
if (mempool) {
@@ -166,7 +166,7 @@ lua_mempool_memory_pool_stat (lua_State *L)
static int
lua_mempool_memory_pool_suggest_size (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
if (mempool) {
lua_pushinteger (L, rspamd_mempool_suggest_size ());
@@ -182,7 +182,7 @@ lua_mempool_memory_pool_suggest_size (lua_State *L)
static int
lua_mempool_memory_pool_set_variable (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
const gchar *var = luaL_checkstring (L, 2),
*value = luaL_checkstring (L, 3);
@@ -201,7 +201,7 @@ lua_mempool_memory_pool_set_variable (lua_State *L)
static int
lua_mempool_memory_pool_get_variable (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = rspamd_lua_check_mempool (L);
const gchar *var = luaL_checkstring (L, 2);
gchar *value;
diff --git a/src/lua/lua_message.c b/src/lua/lua_message.c
index 8dd89c75c..d5a235d2a 100644
--- a/src/lua/lua_message.c
+++ b/src/lua/lua_message.c
@@ -83,7 +83,7 @@ static const struct luaL_reg msglib_m[] = {
LUA_INTERFACE_DEF (message, get_header_strong),
LUA_INTERFACE_DEF (message, set_header),
LUA_INTERFACE_DEF (message, get_date),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -203,7 +203,7 @@ lua_message_get_date (lua_State * L)
gint
luaopen_message (lua_State * L)
{
- lua_newclass (L, "rspamd{message}", msglib_m);
+ rspamd_lua_new_class (L, "rspamd{message}", msglib_m);
luaL_register (L, "rspamd_message", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index c1b52f330..bc4ba594b 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -43,7 +43,7 @@ LUA_FUNCTION_DEF (redis, make_request);
static const struct luaL_reg redislib_m[] = {
LUA_INTERFACE_DEF (redis, make_request),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -102,7 +102,7 @@ lua_redis_push_error (const gchar *err,
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
- lua_setclass (ud->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (ud->L, "rspamd{task}", -1);
*ptask = ud->task;
/* String of error */
@@ -132,7 +132,7 @@ lua_redis_push_data (const redisReply *r, struct lua_redis_userdata *ud)
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
- lua_setclass (ud->L, "rspamd{task}", -1);
+ rspamd_lua_setclass (ud->L, "rspamd{task}", -1);
*ptask = ud->task;
/* Error is nil */
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 53b5d2e05..90b40bef6 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -36,7 +36,7 @@ static const struct luaL_reg regexplib_m[] = {
LUA_INTERFACE_DEF (regexp, match),
LUA_INTERFACE_DEF (regexp, split),
LUA_INTERFACE_DEF (regexp, destroy),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
static const struct luaL_reg regexplib_f[] = {
@@ -121,7 +121,7 @@ lua_regexp_create (lua_State *L)
new->re_flags = regexp_flags;
new->re_pattern = g_strdup (string);
pnew = lua_newuserdata (L, sizeof (struct rspamd_lua_regexp *));
- lua_setclass (L, "rspamd{regexp}", -1);
+ rspamd_lua_setclass (L, "rspamd{regexp}", -1);
*pnew = new;
re_cache_add (new->re_pattern, new, regexp_static_pool);
}
@@ -139,7 +139,7 @@ lua_regexp_get_cached (lua_State *L)
new = re_cache_check (line, regexp_static_pool);
if (new) {
pnew = lua_newuserdata (L, sizeof (struct rspamd_lua_regexp *));
- lua_setclass (L, "rspamd{regexp}", -1);
+ rspamd_lua_setclass (L, "rspamd{regexp}", -1);
*pnew = new;
}
else {
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c
index 40eab8358..c06b14f3f 100644
--- a/src/lua/lua_rsa.c
+++ b/src/lua/lua_rsa.c
@@ -66,7 +66,7 @@ static const struct luaL_reg rsapubkeylib_f[] = {
};
static const struct luaL_reg rsapubkeylib_m[] = {
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_rsa_pubkey_gc},
{NULL, NULL}
};
@@ -78,7 +78,7 @@ static const struct luaL_reg rsaprivkeylib_f[] = {
};
static const struct luaL_reg rsaprivkeylib_m[] = {
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_rsa_privkey_gc},
{NULL, NULL}
};
@@ -91,7 +91,7 @@ static const struct luaL_reg rsasignlib_f[] = {
static const struct luaL_reg rsasignlib_m[] = {
LUA_INTERFACE_DEF (rsa_signature, save),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_rsa_signature_gc},
{NULL, NULL}
};
@@ -147,7 +147,7 @@ lua_rsa_pubkey_load (lua_State *L)
}
else {
prsa = lua_newuserdata (L, sizeof (RSA *));
- lua_setclass (L, "rspamd{rsa_pubkey}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_pubkey}", -1);
*prsa = rsa;
}
fclose (f);
@@ -177,7 +177,7 @@ lua_rsa_pubkey_create (lua_State *L)
}
else {
prsa = lua_newuserdata (L, sizeof (RSA *));
- lua_setclass (L, "rspamd{rsa_pubkey}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_pubkey}", -1);
*prsa = rsa;
}
BIO_free (bp);
@@ -224,7 +224,7 @@ lua_rsa_privkey_load (lua_State *L)
}
else {
prsa = lua_newuserdata (L, sizeof (RSA *));
- lua_setclass (L, "rspamd{rsa_privkey}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_privkey}", -1);
*prsa = rsa;
}
fclose (f);
@@ -254,7 +254,7 @@ lua_rsa_privkey_create (lua_State *L)
}
else {
prsa = lua_newuserdata (L, sizeof (RSA *));
- lua_setclass (L, "rspamd{rsa_privkey}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_privkey}", -1);
*prsa = rsa;
}
BIO_free (bp);
@@ -309,7 +309,7 @@ lua_rsa_signature_load (lua_State *L)
sig->begin = g_malloc (sig->len);
memcpy (sig->begin, data, sig->len);
psig = lua_newuserdata (L, sizeof (f_str_t *));
- lua_setclass (L, "rspamd{rsa_signature}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_signature}", -1);
*psig = sig;
munmap (data, st.st_size);
}
@@ -387,7 +387,7 @@ lua_rsa_signature_create (lua_State *L)
sig->begin = g_malloc (sig->len);
memcpy (sig->begin, data, sig->len);
psig = lua_newuserdata (L, sizeof (f_str_t *));
- lua_setclass (L, "rspamd{rsa_signature}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_signature}", -1);
*psig = sig;
}
@@ -557,7 +557,7 @@ lua_rsa_sign_memory (lua_State *L)
}
else {
psig = lua_newuserdata (L, sizeof (f_str_t *));
- lua_setclass (L, "rspamd{rsa_signature}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_signature}", -1);
*psig = signature;
}
g_free (data_sig);
@@ -625,7 +625,7 @@ lua_rsa_sign_file (lua_State *L)
}
else {
psig = lua_newuserdata (L, sizeof (f_str_t *));
- lua_setclass (L, "rspamd{rsa_signature}", -1);
+ rspamd_lua_setclass (L, "rspamd{rsa_signature}", -1);
*psig = signature;
}
g_free (data_sig);
diff --git a/src/lua/lua_session.c b/src/lua/lua_session.c
index 7cfdcccbe..5abc3aa36 100644
--- a/src/lua/lua_session.c
+++ b/src/lua/lua_session.c
@@ -39,7 +39,7 @@ static const struct luaL_reg sessionlib_m[] = {
LUA_INTERFACE_DEF (session, remove_normal_event),
LUA_INTERFACE_DEF (session, check_session_pending),
LUA_INTERFACE_DEF (session, delete),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -49,7 +49,7 @@ static const struct luaL_reg sessionlib_f[] = {
};
static const struct luaL_reg eventlib_m[] = {
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -156,7 +156,7 @@ lua_session_create (lua_State *L)
return 1;
}
- mempool = lua_check_mempool (L);
+ mempool = rspamd_lua_check_mempool (L);
if (mempool == NULL) {
msg_err ("invalid mempool argument to rspamd_session.create");
lua_pushnil (L);
@@ -196,7 +196,7 @@ lua_session_create (lua_State *L)
cbdata);
cbdata->session = session;
psession = lua_newuserdata (L, sizeof (struct rspamd_async_session *));
- lua_setclass (L, "rspamd{session}", -1);
+ rspamd_lua_setclass (L, "rspamd{session}", -1);
*psession = session;
return 1;
@@ -255,7 +255,7 @@ lua_session_register_async_event (lua_State *L)
cbdata,
g_quark_from_static_string ("lua event"));
pdata = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{event}", -1);
+ rspamd_lua_setclass (L, "rspamd{event}", -1);
*pdata = cbdata;
}
else {
@@ -320,7 +320,7 @@ luaopen_session (lua_State * L)
lua_pop (L, 1); /* remove metatable from stack */
/* Simple event class */
- lua_newclass (L, "rspamd{event}", eventlib_m);
+ rspamd_lua_new_class (L, "rspamd{event}", eventlib_m);
luaL_register (L, "rspamd_event", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 39b6a2041..f0822e086 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -141,7 +141,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, get_metric_action),
LUA_INTERFACE_DEF (task, learn),
LUA_INTERFACE_DEF (task, set_settings),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -162,7 +162,7 @@ static const struct luaL_reg textpartlib_m[] = {
LUA_INTERFACE_DEF (textpart, get_fuzzy),
LUA_INTERFACE_DEF (textpart, get_language),
LUA_INTERFACE_DEF (textpart, compare_distance),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -177,7 +177,7 @@ static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, get_length),
LUA_INTERFACE_DEF (mimepart, get_type),
LUA_INTERFACE_DEF (mimepart, get_filename),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -195,7 +195,7 @@ static const struct luaL_reg imagelib_m[] = {
LUA_INTERFACE_DEF (image, get_type),
LUA_INTERFACE_DEF (image, get_filename),
LUA_INTERFACE_DEF (image, get_size),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -216,7 +216,7 @@ static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF (url, get_text),
LUA_INTERFACE_DEF (url, is_phished),
LUA_INTERFACE_DEF (url, get_phished),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -270,7 +270,7 @@ lua_task_create_empty (lua_State *L)
task = rspamd_task_new (NULL);
ptask = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
return 1;
}
@@ -286,7 +286,7 @@ lua_task_create_from_buffer (lua_State *L)
if (data) {
task = rspamd_task_new (NULL);
ptask = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
task->msg = g_string_new_len (data, len);
}
@@ -320,7 +320,7 @@ lua_task_get_cfg (lua_State *L)
struct rspamd_config **pcfg;
pcfg = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{config}", -1);
+ rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = task->cfg;
return 1;
@@ -357,7 +357,7 @@ lua_task_get_message (lua_State * L)
if (task != NULL && task->message != NULL) {
pmsg = lua_newuserdata (L, sizeof (GMimeMessage *));
- lua_setclass (L, "rspamd{message}", -1);
+ rspamd_lua_setclass (L, "rspamd{message}", -1);
*pmsg = task->message;
}
else {
@@ -374,7 +374,7 @@ lua_task_get_mempool (lua_State * L)
if (task != NULL) {
ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *));
- lua_setclass (L, "rspamd{mempool}", -1);
+ rspamd_lua_setclass (L, "rspamd{mempool}", -1);
*ppool = task->task_pool;
}
else {
@@ -391,7 +391,7 @@ lua_task_get_session (lua_State * L)
if (task != NULL) {
psession = lua_newuserdata (L, sizeof (void *));
- lua_setclass (L, "rspamd{session}", -1);
+ rspamd_lua_setclass (L, "rspamd{session}", -1);
*psession = task->s;
}
else {
@@ -408,7 +408,7 @@ lua_task_get_ev_base (lua_State * L)
if (task != NULL) {
pbase = lua_newuserdata (L, sizeof (struct event_base *));
- lua_setclass (L, "rspamd{ev_base}", -1);
+ rspamd_lua_setclass (L, "rspamd{ev_base}", -1);
*pbase = task->ev_base;
}
else {
@@ -480,7 +480,7 @@ lua_tree_url_callback (gpointer key, gpointer value, gpointer ud)
struct lua_tree_cb_data *cb = ud;
purl = lua_newuserdata (cb->L, sizeof (struct uri *));
- lua_setclass (cb->L, "rspamd{url}", -1);
+ rspamd_lua_setclass (cb->L, "rspamd{url}", -1);
*purl = value;
lua_rawseti (cb->L, -2, cb->i++);
@@ -538,7 +538,7 @@ lua_task_get_text_parts (lua_State * L)
part = cur->data;
ppart = lua_newuserdata (L, sizeof (struct mime_text_part *));
*ppart = part;
- lua_setclass (L, "rspamd{textpart}", -1);
+ rspamd_lua_setclass (L, "rspamd{textpart}", -1);
/* Make it array */
lua_rawseti (L, -2, i++);
cur = g_list_next (cur);
@@ -564,7 +564,7 @@ lua_task_get_parts (lua_State * L)
part = cur->data;
ppart = lua_newuserdata (L, sizeof (struct mime_part *));
*ppart = part;
- lua_setclass (L, "rspamd{mimepart}", -1);
+ rspamd_lua_setclass (L, "rspamd{mimepart}", -1);
/* Make it array */
lua_rawseti (L, -2, i++);
cur = g_list_next (cur);
@@ -632,15 +632,15 @@ lua_task_get_raw_header_common (lua_State * L, gboolean strong)
}
/* Create new associated table for a header */
lua_newtable (L);
- lua_set_table_index (L, "name", rh->name);
- lua_set_table_index (L, "value", rh->value);
+ rspamd_lua_table_set (L, "name", rh->name);
+ rspamd_lua_table_set (L, "value", rh->value);
lua_pushstring (L, "tab_separated");
lua_pushboolean (L, rh->tab_separated);
lua_settable (L, -3);
lua_pushstring (L, "empty_separator");
lua_pushboolean (L, rh->empty_separator);
lua_settable (L, -3);
- lua_set_table_index (L, "separator", rh->separator);
+ rspamd_lua_table_set (L, "separator", rh->separator);
lua_rawseti (L, -2, i++);
/* Process next element */
rh = rh->next;
@@ -687,15 +687,15 @@ lua_task_get_received_headers (lua_State * L)
continue;
}
lua_newtable (L);
- lua_set_table_index (L, "from_hostname", rh->from_hostname);
+ rspamd_lua_table_set (L, "from_hostname", rh->from_hostname);
lua_pushstring (L, "from_ip");
- lua_ip_push_fromstring (L, rh->from_ip);
+ rspamd_lua_ip_push_fromstring (L, rh->from_ip);
lua_settable (L, -3);
- lua_set_table_index (L, "real_hostname", rh->real_hostname);
+ rspamd_lua_table_set (L, "real_hostname", rh->real_hostname);
lua_pushstring (L, "real_ip");
- lua_ip_push_fromstring (L, rh->real_ip);
+ rspamd_lua_ip_push_fromstring (L, rh->real_ip);
lua_settable (L, -3);
- lua_set_table_index (L, "by_hostname", rh->by_hostname);
+ rspamd_lua_table_set (L, "by_hostname", rh->by_hostname);
lua_rawseti (L, -2, i++);
cur = g_list_next (cur);
}
@@ -715,7 +715,7 @@ lua_task_get_resolver (lua_State *L)
if (task != NULL && task->resolver != NULL) {
presolver = lua_newuserdata (L, sizeof (void *));
- lua_setclass (L, "rspamd{resolver}", -1);
+ rspamd_lua_setclass (L, "rspamd{resolver}", -1);
*presolver = task->resolver;
}
else {
@@ -782,8 +782,8 @@ lua_push_internet_address (lua_State *L, InternetAddress *ia)
#ifndef GMIME24
if (internet_address_get_type (ia) == INTERNET_ADDRESS_NAME) {
lua_newtable (L);
- lua_set_table_index (L, "name", internet_address_get_name (ia));
- lua_set_table_index (L, "addr", internet_address_get_addr (ia));
+ rspamd_lua_table_set (L, "name", internet_address_get_name (ia));
+ rspamd_lua_table_set (L, "addr", internet_address_get_addr (ia));
return TRUE;
}
return FALSE;
@@ -795,8 +795,8 @@ lua_push_internet_address (lua_State *L, InternetAddress *ia)
iamb = INTERNET_ADDRESS_MAILBOX (ia);
addr = internet_address_mailbox_get_addr (iamb);
if (addr) {
- lua_set_table_index (L, "name", internet_address_get_name (ia));
- lua_set_table_index (L, "addr", addr);
+ rspamd_lua_table_set (L, "name", internet_address_get_name (ia));
+ rspamd_lua_table_set (L, "addr", addr);
/* Set optional fields */
at = strchr (addr, '@');
@@ -1034,7 +1034,7 @@ lua_task_get_from_ip (lua_State *L)
struct rspamd_task *task = lua_check_task (L);
if (task) {
- lua_ip_push (L, &task->from_addr);
+ rspamd_lua_ip_push (L, &task->from_addr);
}
else {
lua_pushnil (L);
@@ -1064,7 +1064,7 @@ lua_task_get_client_ip_num (lua_State *L)
struct rspamd_task *task = lua_check_task (L);
if (task) {
- lua_ip_push (L, &task->client_addr);
+ rspamd_lua_ip_push (L, &task->client_addr);
}
else {
lua_pushnil (L);
@@ -1166,7 +1166,7 @@ lua_task_get_images (lua_State *L)
lua_newtable (L);
while (cur) {
pimg = lua_newuserdata (L, sizeof (struct rspamd_image *));
- lua_setclass (L, "rspamd{image}", -1);
+ rspamd_lua_setclass (L, "rspamd{image}", -1);
*pimg = cur->data;
lua_rawseti (L, -2, i++);
cur = g_list_next (cur);
@@ -1911,7 +1911,7 @@ lua_url_get_phished (lua_State *L)
if (url) {
if (url->is_phished && url->phished_url != NULL) {
purl = lua_newuserdata (L, sizeof (struct uri *));
- lua_setclass (L, "rspamd{url}", -1);
+ rspamd_lua_setclass (L, "rspamd{url}", -1);
*purl = url->phished_url;
return 1;
@@ -1926,7 +1926,7 @@ lua_url_get_phished (lua_State *L)
gint
luaopen_task (lua_State * L)
{
- lua_newclass_full (L, "rspamd{task}", "rspamd_task", tasklib_m, tasklib_f);
+ rspamd_lua_new_class_full (L, "rspamd{task}", "rspamd_task", tasklib_m, tasklib_f);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1936,7 +1936,7 @@ luaopen_task (lua_State * L)
gint
luaopen_textpart (lua_State * L)
{
- lua_newclass (L, "rspamd{textpart}", textpartlib_m);
+ rspamd_lua_new_class (L, "rspamd{textpart}", textpartlib_m);
luaL_register (L, "rspamd_textpart", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1947,7 +1947,7 @@ luaopen_textpart (lua_State * L)
gint
luaopen_mimepart (lua_State * L)
{
- lua_newclass (L, "rspamd{mimepart}", mimepartlib_m);
+ rspamd_lua_new_class (L, "rspamd{mimepart}", mimepartlib_m);
luaL_register (L, "rspamd_mimepart", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1958,7 +1958,7 @@ luaopen_mimepart (lua_State * L)
gint
luaopen_image (lua_State * L)
{
- lua_newclass (L, "rspamd{image}", imagelib_m);
+ rspamd_lua_new_class (L, "rspamd{image}", imagelib_m);
luaL_register (L, "rspamd_image", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -1969,7 +1969,7 @@ luaopen_image (lua_State * L)
gint
luaopen_url (lua_State * L)
{
- lua_newclass (L, "rspamd{url}", urllib_m);
+ rspamd_lua_new_class (L, "rspamd{url}", urllib_m);
luaL_register (L, "rspamd_url", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c
index 8e7980037..546405126 100644
--- a/src/lua/lua_upstream.c
+++ b/src/lua/lua_upstream.c
@@ -46,7 +46,7 @@ static const struct luaL_reg upstream_list_m[] = {
LUA_INTERFACE_DEF (upstream_list, get_upstream_by_hash),
LUA_INTERFACE_DEF (upstream_list, get_upstream_round_robin),
LUA_INTERFACE_DEF (upstream_list, get_upstream_master_slave),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_upstream_list_destroy},
{NULL, NULL}
};
@@ -73,7 +73,7 @@ static const struct luaL_reg upstream_m[] = {
LUA_INTERFACE_DEF (upstream, get_port),
LUA_INTERFACE_DEF (upstream, get_priority),
LUA_INTERFACE_DEF (upstream, destroy),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
static const struct luaL_reg upstream_f[] = {
@@ -122,7 +122,7 @@ lua_upstream_create (lua_State *L)
}
else {
pnew = lua_newuserdata (L, sizeof (struct lua_upstream *));
- lua_setclass (L, "rspamd{upstream}", -1);
+ rspamd_lua_setclass (L, "rspamd{upstream}", -1);
*pnew = new;
}
}
@@ -333,7 +333,7 @@ lua_upstream_list_create (lua_State *L)
}
}
pnew = lua_newuserdata (L, sizeof (struct upstream_list *));
- lua_setclass (L, "rspamd{upstream_list}", -1);
+ rspamd_lua_setclass (L, "rspamd{upstream_list}", -1);
*pnew = new;
}
@@ -421,7 +421,7 @@ lua_upstream_list_get_upstream_by_hash (lua_State *L)
0);
if (selected) {
pselected = lua_newuserdata (L, sizeof (struct lua_upstream *));
- lua_setclass (L, "rspamd{upstream}", -1);
+ rspamd_lua_setclass (L, "rspamd{upstream}", -1);
*pselected = selected;
}
else {
@@ -469,7 +469,7 @@ lua_upstream_list_get_upstream_round_robin (lua_State *L)
DEFAULT_UPSTREAM_MAXERRORS);
if (selected) {
pselected = lua_newuserdata (L, sizeof (struct lua_upstream *));
- lua_setclass (L, "rspamd{upstream}", -1);
+ rspamd_lua_setclass (L, "rspamd{upstream}", -1);
*pselected = selected;
}
else {
@@ -513,7 +513,7 @@ lua_upstream_list_get_upstream_master_slave (lua_State *L)
DEFAULT_UPSTREAM_MAXERRORS);
if (selected) {
pselected = lua_newuserdata (L, sizeof (struct lua_upstream *));
- lua_setclass (L, "rspamd{upstream}", -1);
+ rspamd_lua_setclass (L, "rspamd{upstream}", -1);
*pselected = selected;
}
else {
diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c
index 762711c30..ebac5bc18 100644
--- a/src/lua/lua_xmlrpc.c
+++ b/src/lua/lua_xmlrpc.c
@@ -30,7 +30,7 @@ LUA_FUNCTION_DEF (xmlrpc, make_request);
static const struct luaL_reg xmlrpclib_m[] = {
LUA_INTERFACE_DEF (xmlrpc, parse_reply),
LUA_INTERFACE_DEF (xmlrpc, make_request),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
diff --git a/src/lua_worker.c b/src/lua_worker.c
index 0473404d6..65c5b9011 100644
--- a/src/lua_worker.c
+++ b/src/lua_worker.c
@@ -95,7 +95,7 @@ static const struct luaL_reg lua_workerlib_m[] = {
LUA_INTERFACE_DEF (worker, get_option),
LUA_INTERFACE_DEF (worker, get_resolver),
LUA_INTERFACE_DEF (worker, get_cfg),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -103,7 +103,7 @@ static const struct luaL_reg lua_workerlib_m[] = {
static gint
luaopen_lua_worker (lua_State * L)
{
- lua_newclass (L, "rspamd{worker}", lua_workerlib_m);
+ rspamd_lua_new_class (L, "rspamd{worker}", lua_workerlib_m);
luaL_register (L, "rspamd_worker", null_reg);
lua_pop (L, 1); /* remove metatable from stack */
@@ -127,7 +127,7 @@ lua_worker_get_ev_base (lua_State *L)
if (ctx) {
pbase = lua_newuserdata (L, sizeof (struct event_base *));
- lua_setclass (L, "rspamd{ev_base}", -1);
+ rspamd_lua_setclass (L, "rspamd{ev_base}", -1);
*pbase = ctx->ev_base;
}
else {
@@ -222,7 +222,7 @@ lua_worker_get_resolver (lua_State *L)
if (ctx) {
presolver = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{resolver}", -1);
+ rspamd_lua_setclass (L, "rspamd{resolver}", -1);
*presolver = ctx->resolver;
}
else {
@@ -240,7 +240,7 @@ lua_worker_get_cfg (lua_State *L)
if (ctx) {
pcfg = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{config}", -1);
+ rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = ctx->cfg;
}
else {
@@ -284,7 +284,7 @@ lua_accept_socket (gint fd, short what, void *arg)
/* Call finalizer function */
lua_rawgeti (L, LUA_REGISTRYINDEX, ctx->cbref_accept);
pctx = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{worker}", -1);
+ rspamd_lua_setclass (L, "rspamd{worker}", -1);
*pctx = ctx;
lua_pushinteger (L, nfd);
lua_pushstring (L, rspamd_inet_address_to_string (&addr));
@@ -371,7 +371,7 @@ start_lua_worker (struct rspamd_worker *worker)
}
pctx = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{worker}", -1);
+ rspamd_lua_setclass (L, "rspamd{worker}", -1);
lua_setglobal (L, "rspamd_worker");
*pctx = ctx;
@@ -395,7 +395,7 @@ start_lua_worker (struct rspamd_worker *worker)
/* Call finalizer function */
lua_rawgeti (L, LUA_REGISTRYINDEX, ctx->cbref_fin);
pctx = lua_newuserdata (L, sizeof (gpointer));
- lua_setclass (L, "rspamd{worker}", -1);
+ rspamd_lua_setclass (L, "rspamd{worker}", -1);
*pctx = ctx;
if (lua_pcall (L, 1, 0, 0) != 0) {
msg_info ("call to worker finalizer failed: %s", lua_tostring (L,
diff --git a/src/main.c b/src/main.c
index 6e9f75e7a..77143d1f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -406,7 +406,7 @@ reread_config (struct rspamd_main *rspamd)
rspamd->cfg->cfg_name);
/* Save some variables */
tmp_cfg->cfg_name = cfg_file;
- tmp_cfg->lua_state = init_lua (tmp_cfg);
+ tmp_cfg->lua_state = rspamd_lua_init (tmp_cfg);
rspamd_mempool_add_destructor (tmp_cfg->cfg_pool,
(rspamd_mempool_destruct_t)lua_close, tmp_cfg->lua_state);
@@ -445,7 +445,7 @@ reread_config (struct rspamd_main *rspamd)
}
l = g_list_next (l);
}
- init_lua_filters (rspamd->cfg);
+ rspamd_init_lua_filters (rspamd->cfg);
init_cfg_cache (rspamd->cfg);
msg_info ("config rereaded successfully");
}
@@ -1207,7 +1207,7 @@ main (gint argc, gchar **argv, gchar **env)
g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
detect_priv (rspamd_main);
- rspamd_main->cfg->lua_state = init_lua (rspamd_main->cfg);
+ rspamd_main->cfg->lua_state = rspamd_lua_init (rspamd_main->cfg);
rspamd_mempool_add_destructor (rspamd_main->cfg->cfg_pool,
(rspamd_mempool_destruct_t)lua_close, rspamd_main->cfg->lua_state);
@@ -1264,7 +1264,7 @@ main (gint argc, gchar **argv, gchar **env)
/* Init events to test modules */
event_init ();
res = TRUE;
- if (!init_lua_filters (rspamd_main->cfg)) {
+ if (!rspamd_init_lua_filters (rspamd_main->cfg)) {
res = FALSE;
}
/* Perform modules configuring */
@@ -1337,7 +1337,7 @@ main (gint argc, gchar **argv, gchar **env)
g_mime_init (0);
/* Init lua filters */
- if (!init_lua_filters (rspamd_main->cfg)) {
+ if (!rspamd_init_lua_filters (rspamd_main->cfg)) {
msg_err ("error loading lua plugins");
exit (EXIT_FAILURE);
}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 31d4943fd..2bb7ebada 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -76,7 +76,7 @@ LUA_FUNCTION_DEF (regexp, match);
static const struct luaL_reg regexplib_m[] = {
LUA_INTERFACE_DEF (regexp, match),
- {"__tostring", lua_class_tostring},
+ {"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -1227,7 +1227,7 @@ maybe_call_lua_function (const gchar *name,
lua_getglobal (L, name);
if (lua_isfunction (L, -1)) {
ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- lua_setclass (L, "rspamd{task}", -1);
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
*ptask = task;
/* Call function */
if (lua_pcall (L, 1, 1, 0) != 0) {
@@ -1505,7 +1505,7 @@ process_regexp_item (struct rspamd_task *task, void *user_data)
sizeof (GMutex));
g_mutex_init (workers_mtx);
#endif
- nL = init_lua_locked (task->cfg);
+ nL = rspamd_init_lua_locked (task->cfg);
luaopen_regexp (nL->L);
regexp_module_ctx->workers = g_thread_pool_new (
process_regexp_item_threaded,
@@ -1538,7 +1538,7 @@ process_regexp_item (struct rspamd_task *task, void *user_data)
/* Non-threaded version */
if (item->lua_function) {
/* Just call function */
- if (lua_call_expression_func (item->lua_function, task, NULL,
+ if (rspamd_lua_call_expression_func (item->lua_function, task, NULL,
&res) && res) {
insert_result (task, item->symbol, 1, NULL);
}
diff --git a/src/smtp.c b/src/smtp.c
index 98b012e3e..436cc1526 100644
--- a/src/smtp.c
+++ b/src/smtp.c
@@ -319,7 +319,7 @@ process_smtp_data (struct smtp_session *session)
}
}
else {
- lua_call_pre_filters (session->task);
+ rspamd_lua_call_pre_filters (session->task);
/* We want fin_task after pre filters are processed */
session->task->s->wanna_die = TRUE;
session->task->state = WAIT_PRE_FILTER;
diff --git a/src/worker.c b/src/worker.c
index 77cb9fcd1..c0e8cacd2 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -318,7 +318,7 @@ start_worker (struct rspamd_worker *worker)
/* Create classify pool */
ctx->classify_pool = NULL;
if (ctx->classify_threads > 1) {
- nL = init_lua_locked (worker->srv->cfg);
+ nL = rspamd_init_lua_locked (worker->srv->cfg);
ctx->classify_pool = g_thread_pool_new (process_statfiles_threaded,
nL,
ctx->classify_threads,