};
/* Utility functions */
-static struct rspamd_task *
-lua_check_task (lua_State * L)
+struct rspamd_task *
+lua_check_task (lua_State * L, gint pos)
{
void *ud = luaL_checkudata (L, 1, "rspamd{task}");
luaL_argcheck (L, ud != NULL, 1, "'task' expected");
static int
lua_task_process_message (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL && task->msg.len > 0) {
if (process_message (task) == 0) {
static int
lua_task_get_cfg (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct rspamd_config **pcfg;
pcfg = lua_newuserdata (L, sizeof (gpointer));
static int
lua_task_set_cfg (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
void *ud = luaL_checkudata (L, 2, "rspamd{config}");
luaL_argcheck (L, ud != NULL, 1, "'config' expected");
static int
lua_task_destroy (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
rspamd_task_free (task, FALSE);
lua_task_get_message (lua_State * L)
{
GMimeMessage **pmsg;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL && task->message != NULL) {
pmsg = lua_newuserdata (L, sizeof (GMimeMessage *));
lua_task_get_mempool (lua_State * L)
{
rspamd_mempool_t **ppool;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *));
lua_task_get_session (lua_State * L)
{
struct rspamd_async_session **psession;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
psession = lua_newuserdata (L, sizeof (void *));
lua_task_get_ev_base (lua_State * L)
{
struct event_base **pbase;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
pbase = lua_newuserdata (L, sizeof (struct event_base *));
static gint
lua_task_insert_result (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol_name, *param;
double flag;
GList *params = NULL;
static gint
lua_task_set_pre_result (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct metric_result *mres;
gchar *action_str;
gint action = METRIC_ACTION_MAX;
static gint
lua_task_get_urls (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct lua_tree_cb_data cb;
if (task) {
static gint
lua_task_get_content (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
lua_pushlstring (L, task->msg.start, task->msg.len);
static gint
lua_task_get_emails (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct lua_tree_cb_data cb;
if (task) {
lua_task_get_text_parts (lua_State * L)
{
gint i = 1;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
GList *cur;
struct mime_text_part *part, **ppart;
lua_task_get_parts (lua_State * L)
{
gint i = 1;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
GList *cur;
struct mime_part *part, **ppart;
lua_task_get_header_common (lua_State *L, gboolean full, gboolean raw)
{
gboolean strong = FALSE;
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *name;
name = luaL_checkstring (L, 2);
static gint
lua_task_get_received_headers (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
GList *cur;
struct received_header *rh;
gint i = 1;
static gint
lua_task_get_resolver (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct rspamd_dns_resolver **presolver;
if (task != NULL && task->resolver != NULL) {
static gint
lua_task_inc_dns_req (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
task->dns_requests++;
static gint
lua_task_call_rspamd_function (lua_State * L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
struct expression_function f;
gint i, top;
gboolean res;
static gint
lua_task_get_recipients (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
InternetAddressList *addrs;
gint what = 0;
static gint
lua_task_get_from (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
InternetAddressList *addrs;
gint what = 0;
static gint
lua_task_get_user (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task && task->user != NULL) {
lua_pushstring (L, task->user);
static gint
lua_task_set_user (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *new_user;
if (task) {
static gint
lua_task_get_from_ip (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
rspamd_lua_ip_push (L, &task->from_addr);
static gint
lua_task_get_client_ip (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
rspamd_lua_ip_push (L, &task->client_addr);
static gint
lua_task_get_helo (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
if (task->helo != NULL) {
static gint
lua_task_set_helo (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *new_helo;
if (task) {
static gint
lua_task_get_hostname (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
if (task->hostname != NULL) {
static gint
lua_task_set_hostname (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *new_hostname;
if (task) {
static gint
lua_task_get_images (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
gint i = 1;
GList *cur;
struct rspamd_image **pimg;
static gint
lua_task_get_symbol (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol;
struct metric *metric;
GList *cur = NULL, *metric_list;
static gint
lua_task_get_date (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
gdouble tim;
enum lua_date_type type = DATE_CONNECT;
gboolean gmt = TRUE;
static gint
lua_task_get_message_id (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL && task->message_id != NULL) {
lua_pushstring (L, task->message_id);
static gint
lua_task_get_timeval (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
lua_newtable (L);
static gint
lua_task_learn (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
gboolean is_spam = FALSE;
const gchar *clname;
struct rspamd_classifier_config *cl;
static gint
lua_task_set_settings (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
ucl_object_t *settings;
settings = ucl_object_lua_import (L, 2);
static gint
lua_task_get_metric_score (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *metric_name;
struct metric_result *metric_res;
static gint
lua_task_get_metric_action (lua_State *L)
{
- struct rspamd_task *task = lua_check_task (L);
+ struct rspamd_task *task = lua_check_task (L, 1);
const gchar *metric_name;
struct metric_result *metric_res;
enum rspamd_metric_action action;