Update to 0.4.3.
SET(RSPAMD_VERSION_MAJOR 0)
SET(RSPAMD_VERSION_MINOR 4)
-SET(RSPAMD_VERSION_PATCH 2)
+SET(RSPAMD_VERSION_PATCH 3)
SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
*/
#include "config.h"
-#include "librspamdclient.h"
+#include "../../lib/librspamdclient.h"
#define PRINT_FUNC printf
switch (expected_type) {
case LUA_VAR_NUM:
if (!lua_isnumber (L, -1)) {
+ lua_pop (L, 1);
*res = NULL;
return FALSE;
}
num_res = lua_tonumber (L, -1);
*res = memory_pool_alloc (task->task_pool, sizeof (double));
**(double **)res = num_res;
+ lua_pop (L, 1);
return TRUE;
case LUA_VAR_BOOLEAN:
if (!lua_isboolean (L, -1)) {
+ lua_pop (L, 1);
*res = NULL;
return FALSE;
}
bool_res = lua_toboolean (L, -1);
*res = memory_pool_alloc (task->task_pool, sizeof (gboolean));
**(gboolean **)res = bool_res;
+ lua_pop (L, 1);
return TRUE;
case LUA_VAR_STRING:
if (!lua_isstring (L, -1)) {
+ lua_pop (L, 1);
*res = NULL;
return FALSE;
}
str_res = memory_pool_strdup (task->task_pool, lua_tostring (L, -1));
*res = str_res;
+ lua_pop (L, 1);
return TRUE;
case LUA_VAR_FUNCTION:
case LUA_VAR_UNKNOWN:
+ lua_pop (L, 1);
msg_err ("cannot expect function or unknown types");
*res = NULL;
return FALSE;
}
lua_pop (L, 1);
}
- lua_pop (L, 1);
}
+ lua_pop (L, 1);
}
return res;
struct classifier_callback_data *cd;
lua_State *L;
-
/* Go throught all callbacks and call them, appending results to list */
cur = g_list_first (ccf->pre_callbacks);
while (cur) {
if (lua_isfunction (L, -1)) {
res = call_classifier_pre_callback (ccf, task, L, is_learn, is_spam);
}
+ lua_pop (L, 1);
}
+ lua_pop (L, 1);
}
-
return res;
}
if (lua_isnumber (cd->L, 1)) {
out = lua_tonumber (cd->L, 1);
}
+ lua_pop (cd->L, 1);
}
cur = g_list_next (cur);
struct worker_task **ptask;
GList *cur;
struct expression_argument *arg;
- int nargs = 1;
+ int nargs = 1, pop = 0;
/* Call specified function and expect result of given expected_type */
/* First check function in config table */
lua_gettable (L, -2);
if (lua_isnil (L, -1)) {
/* Try to get global variable */
+ lua_pop (L, 1);
lua_getglobal (L, function);
}
else {
/* Call local function in table */
lua_pushstring (L, function);
lua_gettable (L, -2);
+ pop += 2;
}
}
else {
/* Try to get global variable */
+ lua_pop (L, 1);
lua_getglobal (L, function);
}
if (lua_isnil (L, -1)) {
+ if (pop > 0) {
+ lua_pop (L, pop);
+ }
msg_err ("function with name %s is not defined", function);
return FALSE;
}
msg_info ("call to %s failed: %s", function, lua_tostring (L, -1));
return FALSE;
}
+ pop ++;
if (!lua_isboolean (L, -1)) {
+ lua_pop (L, pop);
msg_info ("function %s must return a boolean", function);
return FALSE;
}
*res = lua_toboolean (L, -1);
-
+ lua_pop (L, pop);
+
return TRUE;
}
msg_info ("function %s must return a number", p->data);
}
res = lua_tonumber (L, -1);
+ lua_pop (L, 1);
return res;
}
if (lua_isboolean (cd->L, 1)) {
res = lua_toboolean (cd->L, 1);
}
+ lua_pop (cd->L, 1);
}
return res;
lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
- if (lua_pcall (cd->L, 1, 1, 0) != 0) {
+ if (lua_pcall (cd->L, 1, 0, 0) != 0) {
msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
cur = g_list_next (cur);
{
struct lua_callback_data *cd = ud;
struct worker_task **ptask;
-
lua_getglobal (cd->L, cd->name);
ptask = lua_newuserdata (cd->L, sizeof (struct worker_task *));
lua_setclass (cd->L, "rspamd{task}", -1);
*ptask = task;
- if (lua_pcall (cd->L, 1, 1, 0) != 0) {
+ if (lua_pcall (cd->L, 1, 0, 0) != 0) {
msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
}
{
lua_State *L = task->cfg->lua_state;
struct worker_task **ptask;
+ gboolean res;
lua_getglobal (L, name);
if (lua_isfunction (L, -1)) {
msg_info ("call to %s failed: %s", (gchar *)name, lua_tostring (L, -1));
return FALSE;
}
- return lua_toboolean (L, -1);
+ res = lua_toboolean (L, -1);
+ lua_pop (L, 1);
+ return res;
+ }
+ else {
+ lua_pop (L, 1);
}
-
return FALSE;
}
new_task->rcpt = g_list_reverse (new_task->rcpt);
}
#endif
-
}
#ifndef BUILD_STATIC