diff options
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 599 |
1 files changed, 320 insertions, 279 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 0572226be..1b62ee83f 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -39,8 +39,11 @@ #include "statfile_sync.h" #include "diff.h" -extern stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct rspamd_classifier_config *ccf, - const gchar *symbol, struct rspamd_statfile_config **st, gboolean try_create); +extern stat_file_t * get_statfile_by_symbol (statfile_pool_t *pool, + struct rspamd_classifier_config *ccf, + const gchar *symbol, + struct rspamd_statfile_config **st, + gboolean try_create); /* Task creation */ LUA_FUNCTION_DEF (task, create_empty); @@ -90,13 +93,13 @@ LUA_FUNCTION_DEF (task, get_metric_score); LUA_FUNCTION_DEF (task, get_metric_action); LUA_FUNCTION_DEF (task, learn_statfile); -static const struct luaL_reg tasklib_f[] = { +static const struct luaL_reg tasklib_f[] = { LUA_INTERFACE_DEF (task, create_empty), LUA_INTERFACE_DEF (task, create_from_buffer), {NULL, NULL} }; -static const struct luaL_reg tasklib_m[] = { +static const struct luaL_reg tasklib_m[] = { LUA_INTERFACE_DEF (task, get_message), LUA_INTERFACE_DEF (task, destroy), LUA_INTERFACE_DEF (task, process_message), @@ -153,7 +156,7 @@ LUA_FUNCTION_DEF (textpart, get_fuzzy); LUA_FUNCTION_DEF (textpart, get_language); LUA_FUNCTION_DEF (textpart, compare_distance); -static const struct luaL_reg textpartlib_m[] = { +static const struct luaL_reg textpartlib_m[] = { LUA_INTERFACE_DEF (textpart, get_content), LUA_INTERFACE_DEF (textpart, get_length), LUA_INTERFACE_DEF (textpart, is_empty), @@ -171,7 +174,7 @@ LUA_FUNCTION_DEF (mimepart, get_length); LUA_FUNCTION_DEF (mimepart, get_type); LUA_FUNCTION_DEF (mimepart, get_filename); -static const struct luaL_reg mimepartlib_m[] = { +static const struct luaL_reg mimepartlib_m[] = { LUA_INTERFACE_DEF (mimepart, get_content), LUA_INTERFACE_DEF (mimepart, get_length), LUA_INTERFACE_DEF (mimepart, get_type), @@ -188,7 +191,7 @@ LUA_FUNCTION_DEF (image, get_type); LUA_FUNCTION_DEF (image, get_filename); LUA_FUNCTION_DEF (image, get_size); -static const struct luaL_reg imagelib_m[] = { +static const struct luaL_reg imagelib_m[] = { LUA_INTERFACE_DEF (image, get_width), LUA_INTERFACE_DEF (image, get_height), LUA_INTERFACE_DEF (image, get_type), @@ -207,7 +210,7 @@ LUA_FUNCTION_DEF (url, get_text); LUA_FUNCTION_DEF (url, is_phished); LUA_FUNCTION_DEF (url, get_phished); -static const struct luaL_reg urllib_m[] = { +static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, get_length), LUA_INTERFACE_DEF (url, get_host), LUA_INTERFACE_DEF (url, get_user), @@ -220,42 +223,42 @@ static const struct luaL_reg urllib_m[] = { }; /* Utility functions */ -static struct rspamd_task * +static struct rspamd_task * lua_check_task (lua_State * L) { - void *ud = luaL_checkudata (L, 1, "rspamd{task}"); + void *ud = luaL_checkudata (L, 1, "rspamd{task}"); luaL_argcheck (L, ud != NULL, 1, "'task' expected"); return ud ? *((struct rspamd_task **)ud) : NULL; } -static struct mime_text_part * +static struct mime_text_part * lua_check_textpart (lua_State * L) { - void *ud = luaL_checkudata (L, 1, "rspamd{textpart}"); + void *ud = luaL_checkudata (L, 1, "rspamd{textpart}"); luaL_argcheck (L, ud != NULL, 1, "'textpart' expected"); return ud ? *((struct mime_text_part **)ud) : NULL; } -static struct mime_part * +static struct mime_part * lua_check_mimepart (lua_State * L) { - void *ud = luaL_checkudata (L, 1, "rspamd{mimepart}"); + void *ud = luaL_checkudata (L, 1, "rspamd{mimepart}"); luaL_argcheck (L, ud != NULL, 1, "'mimepart' expected"); return ud ? *((struct mime_part **)ud) : NULL; } -static struct rspamd_image * +static struct rspamd_image * lua_check_image (lua_State * L) { - void *ud = luaL_checkudata (L, 1, "rspamd{image}"); + void *ud = luaL_checkudata (L, 1, "rspamd{image}"); luaL_argcheck (L, ud != NULL, 1, "'image' expected"); return ud ? *((struct rspamd_image **)ud) : NULL; } -static struct uri * +static struct uri * lua_check_url (lua_State * L) { - void *ud = luaL_checkudata (L, 1, "rspamd{url}"); + void *ud = luaL_checkudata (L, 1, "rspamd{url}"); luaL_argcheck (L, ud != NULL, 1, "'url' expected"); return ud ? *((struct uri **)ud) : NULL; } @@ -265,7 +268,7 @@ lua_check_url (lua_State * L) static int lua_task_create_empty (lua_State *L) { - struct rspamd_task **ptask, *task; + struct rspamd_task **ptask, *task; task = rspamd_task_new (NULL); ptask = lua_newuserdata (L, sizeof (gpointer)); @@ -277,9 +280,9 @@ lua_task_create_empty (lua_State *L) static int lua_task_create_from_buffer (lua_State *L) { - struct rspamd_task **ptask, *task; - const gchar *data; - size_t len; + struct rspamd_task **ptask, *task; + const gchar *data; + size_t len; data = luaL_checklstring (L, 1, &len); if (data) { @@ -295,7 +298,7 @@ lua_task_create_from_buffer (lua_State *L) 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); if (task != NULL && task->msg != NULL && task->msg->len > 0) { if (process_message (task) == 0) { @@ -314,8 +317,8 @@ lua_task_process_message (lua_State *L) static int lua_task_set_cfg (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - void *ud = luaL_checkudata (L, 2, "rspamd{config}"); + struct rspamd_task *task = lua_check_task (L); + void *ud = luaL_checkudata (L, 2, "rspamd{config}"); luaL_argcheck (L, ud != NULL, 1, "'config' expected"); task->cfg = ud ? *((struct rspamd_config **)ud) : NULL; @@ -325,7 +328,7 @@ lua_task_set_cfg (lua_State *L) static int lua_task_destroy (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); + struct rspamd_task *task = lua_check_task (L); if (task != NULL) { rspamd_task_free (task, FALSE); @@ -337,8 +340,8 @@ lua_task_destroy (lua_State *L) static int lua_task_get_message (lua_State * L) { - GMimeMessage **pmsg; - struct rspamd_task *task = lua_check_task (L); + GMimeMessage **pmsg; + struct rspamd_task *task = lua_check_task (L); if (task != NULL && task->message != NULL) { pmsg = lua_newuserdata (L, sizeof (GMimeMessage *)); @@ -354,8 +357,8 @@ lua_task_get_message (lua_State * L) static int lua_task_get_mempool (lua_State * L) { - rspamd_mempool_t **ppool; - struct rspamd_task *task = lua_check_task (L); + rspamd_mempool_t **ppool; + struct rspamd_task *task = lua_check_task (L); if (task != NULL) { ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *)); @@ -371,8 +374,8 @@ lua_task_get_mempool (lua_State * L) static int lua_task_get_session (lua_State * L) { - struct rspamd_async_session **psession; - struct rspamd_task *task = lua_check_task (L); + struct rspamd_async_session **psession; + struct rspamd_task *task = lua_check_task (L); if (task != NULL) { psession = lua_newuserdata (L, sizeof (void *)); @@ -388,8 +391,8 @@ lua_task_get_session (lua_State * L) static int lua_task_get_ev_base (lua_State * L) { - struct event_base **pbase; - struct rspamd_task *task = lua_check_task (L); + struct event_base **pbase; + struct rspamd_task *task = lua_check_task (L); if (task != NULL) { pbase = lua_newuserdata (L, sizeof (struct event_base *)); @@ -405,20 +408,23 @@ lua_task_get_ev_base (lua_State * L) static gint lua_task_insert_result (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *symbol_name, *param; - double flag; - GList *params = NULL; - gint i, top; + struct rspamd_task *task = lua_check_task (L); + const gchar *symbol_name, *param; + double flag; + GList *params = NULL; + gint i, top; if (task != NULL) { - symbol_name = rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 2)); + symbol_name = + rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 2)); flag = luaL_checknumber (L, 3); top = lua_gettop (L); /* Get additional options */ for (i = 4; i <= top; i++) { param = luaL_checkstring (L, i); - params = g_list_prepend (params, rspamd_mempool_strdup (task->task_pool, param)); + params = + g_list_prepend (params, + rspamd_mempool_strdup (task->task_pool, param)); } insert_result (task, symbol_name, flag, params); @@ -429,16 +435,17 @@ lua_task_insert_result (lua_State * L) static gint lua_task_set_pre_result (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - gchar *action_str; - guint action; + struct rspamd_task *task = lua_check_task (L); + gchar *action_str; + guint action; if (task != NULL) { action = luaL_checkinteger (L, 2); if (action < task->pre_result.action) { task->pre_result.action = action; if (lua_gettop (L) >= 3) { - action_str = rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 3)); + action_str = rspamd_mempool_strdup (task->task_pool, + luaL_checkstring (L, 3)); task->pre_result.str = action_str; } else { @@ -450,15 +457,15 @@ lua_task_set_pre_result (lua_State * L) } struct lua_tree_cb_data { - lua_State *L; - int i; + lua_State *L; + int i; }; static gboolean lua_tree_url_callback (gpointer key, gpointer value, gpointer ud) { - struct uri **purl; - struct lua_tree_cb_data *cb = ud; + struct uri **purl; + struct lua_tree_cb_data *cb = ud; purl = lua_newuserdata (cb->L, sizeof (struct uri *)); lua_setclass (cb->L, "rspamd{url}", -1); @@ -471,8 +478,8 @@ lua_tree_url_callback (gpointer key, gpointer value, gpointer ud) static gint lua_task_get_urls (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - struct lua_tree_cb_data cb; + struct rspamd_task *task = lua_check_task (L); + struct lua_tree_cb_data cb; if (task) { lua_newtable (L); @@ -489,8 +496,8 @@ lua_task_get_urls (lua_State * L) static gint lua_task_get_emails (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - struct lua_tree_cb_data cb; + struct rspamd_task *task = lua_check_task (L); + struct lua_tree_cb_data cb; if (task) { lua_newtable (L); @@ -507,10 +514,10 @@ lua_task_get_emails (lua_State * L) static gint lua_task_get_text_parts (lua_State * L) { - gint i = 1; - struct rspamd_task *task = lua_check_task (L); - GList *cur; - struct mime_text_part *part, **ppart; + gint i = 1; + struct rspamd_task *task = lua_check_task (L); + GList *cur; + struct mime_text_part *part, **ppart; if (task != NULL) { lua_newtable (L); @@ -533,10 +540,10 @@ lua_task_get_text_parts (lua_State * L) static gint lua_task_get_parts (lua_State * L) { - gint i = 1; - struct rspamd_task *task = lua_check_task (L); - GList *cur; - struct mime_part *part, **ppart; + gint i = 1; + struct rspamd_task *task = lua_check_task (L); + GList *cur; + struct mime_part *part, **ppart; if (task != NULL) { lua_newtable (L); @@ -560,7 +567,7 @@ lua_task_get_parts (lua_State * L) static gint lua_task_get_raw_headers (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); + struct rspamd_task *task = lua_check_task (L); if (task) { lua_pushstring (L, task->raw_headers_str); @@ -575,10 +582,10 @@ lua_task_get_raw_headers (lua_State * L) static gint lua_task_get_raw_header_common (lua_State * L, gboolean strong) { - struct rspamd_task *task = lua_check_task (L); - struct raw_header *rh; - gint i = 1; - const gchar *name; + struct rspamd_task *task = lua_check_task (L); + struct raw_header *rh; + gint i = 1; + const gchar *name; if (task) { name = luaL_checkstring (L, 2); @@ -613,7 +620,7 @@ 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, "name", rh->name); lua_set_table_index (L, "value", rh->value); lua_pushstring (L, "tab_separated"); lua_pushboolean (L, rh->tab_separated); @@ -649,17 +656,17 @@ lua_task_get_raw_header_strong (lua_State * L) static gint lua_task_get_received_headers (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - GList *cur; - struct received_header *rh; - gint i = 1; + struct rspamd_task *task = lua_check_task (L); + GList *cur; + struct received_header *rh; + gint i = 1; if (task) { lua_newtable (L); cur = g_list_first (task->received); while (cur) { rh = cur->data; - if (rh->is_error || G_UNLIKELY( + if (rh->is_error || G_UNLIKELY ( rh->from_ip == NULL && rh->real_ip == NULL && rh->real_hostname == NULL && @@ -691,8 +698,8 @@ lua_task_get_received_headers (lua_State * L) static gint lua_task_get_resolver (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - struct rspamd_dns_resolver **presolver; + struct rspamd_task *task = lua_check_task (L); + struct rspamd_dns_resolver **presolver; if (task != NULL && task->resolver != NULL) { presolver = lua_newuserdata (L, sizeof (void *)); @@ -709,10 +716,10 @@ lua_task_get_resolver (lua_State *L) 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); if (task != NULL) { - task->dns_requests ++; + task->dns_requests++; } return 0; @@ -721,11 +728,11 @@ lua_task_inc_dns_req (lua_State *L) static gint lua_task_call_rspamd_function (lua_State * L) { - struct rspamd_task *task = lua_check_task (L); - struct expression_function f; - gint i, top; - gboolean res; - gchar *arg; + struct rspamd_task *task = lua_check_task (L); + struct expression_function f; + gint i, top; + gboolean res; + gchar *arg; if (task) { f.name = (gchar *)luaL_checkstring (L, 2); @@ -769,12 +776,13 @@ lua_push_internet_address (lua_State *L, InternetAddress *ia) } return FALSE; #else - InternetAddressMailbox *iamb; + InternetAddressMailbox *iamb; if (ia && INTERNET_ADDRESS_IS_MAILBOX (ia)) { lua_newtable (L); iamb = INTERNET_ADDRESS_MAILBOX (ia); lua_set_table_index (L, "name", internet_address_get_name (ia)); - lua_set_table_index (L, "addr", internet_address_mailbox_get_addr (iamb)); + lua_set_table_index (L, "addr", + internet_address_mailbox_get_addr (iamb)); return TRUE; } return FALSE; @@ -787,12 +795,12 @@ lua_push_internet_address (lua_State *L, InternetAddress *ia) static void lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs) { - InternetAddress *ia; - gint idx = 1; + InternetAddress *ia; + gint idx = 1; #ifndef GMIME24 /* Gmime 2.2 version */ - InternetAddressList *cur; + InternetAddressList *cur; lua_newtable (L); cur = addrs; @@ -805,12 +813,12 @@ lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs) } #else /* Gmime 2.4 version */ - gsize len, i; + gsize len, i; lua_newtable (L); if (addrs != NULL) { len = internet_address_list_length (addrs); - for (i = 0; i < len; i ++) { + for (i = 0; i < len; i++) { ia = internet_address_list_get_address (addrs, i); if (lua_push_internet_address (L, ia)) { lua_rawseti (L, -2, idx++); @@ -823,10 +831,10 @@ lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs) static gint lua_task_get_recipients (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - GList *cur; - InternetAddressList *addrs; - gint idx = 1; + struct rspamd_task *task = lua_check_task (L); + GList *cur; + InternetAddressList *addrs; + gint idx = 1; if (task) { cur = task->rcpt; @@ -836,7 +844,8 @@ lua_task_get_recipients (lua_State *L) #ifndef GMIME24 addrs = internet_address_parse_string (cur->data); if (addrs) { - if (lua_push_internet_address (L, internet_address_list_get_address (addrs))) { + if (lua_push_internet_address (L, + internet_address_list_get_address (addrs))) { lua_rawseti (L, -2, idx++); } internet_address_list_destroy (addrs); @@ -845,7 +854,8 @@ lua_task_get_recipients (lua_State *L) addrs = internet_address_list_parse_string (cur->data); if (addrs) { - if (lua_push_internet_address (L, internet_address_list_get_address (addrs, 0))) { + if (lua_push_internet_address (L, + internet_address_list_get_address (addrs, 0))) { lua_rawseti (L, -2, idx++); } g_object_unref (addrs); @@ -864,9 +874,9 @@ lua_task_get_recipients (lua_State *L) static gint lua_task_get_from (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - InternetAddressList *addrs; - + struct rspamd_task *task = lua_check_task (L); + InternetAddressList *addrs; + if (task) { if (task->from != NULL) { #ifndef GMIME24 @@ -876,7 +886,7 @@ lua_task_get_from (lua_State *L) #endif if (addrs != NULL) { lua_push_internet_address_list (L, addrs); -#ifndef GMIME24 +#ifndef GMIME24 internet_address_list_destroy (addrs); #else g_object_unref (addrs); @@ -897,8 +907,8 @@ lua_task_get_from (lua_State *L) static gint lua_task_set_from (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *new_from; + struct rspamd_task *task = lua_check_task (L); + const gchar *new_from; if (task) { new_from = luaL_checkstring (L, 2); @@ -913,7 +923,7 @@ lua_task_set_from (lua_State *L) 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); if (task && task->user != NULL) { lua_pushstring (L, task->user); @@ -927,8 +937,8 @@ lua_task_get_user (lua_State *L) static gint lua_task_set_user (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *new_user; + struct rspamd_task *task = lua_check_task (L); + const gchar *new_user; if (task) { new_user = luaL_checkstring (L, 2); @@ -946,7 +956,7 @@ lua_task_set_user (lua_State *L) static gint lua_task_get_recipients_headers (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); + struct rspamd_task *task = lua_check_task (L); if (task && task->rcpts) { lua_push_internet_address_list (L, task->rcpts); @@ -960,18 +970,22 @@ lua_task_get_recipients_headers (lua_State *L) static gint lua_task_get_from_headers (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - InternetAddressList *addrs; + struct rspamd_task *task = lua_check_task (L); + InternetAddressList *addrs; if (task && task->message != NULL) { #ifndef GMIME24 - addrs = internet_address_parse_string (g_mime_message_get_sender (task->message)); + addrs = + internet_address_parse_string (g_mime_message_get_sender ( + task->message)); #else - addrs = internet_address_list_parse_string (g_mime_message_get_sender (task->message)); + addrs = + internet_address_list_parse_string (g_mime_message_get_sender (task + ->message)); #endif if (addrs) { lua_push_internet_address_list (L, addrs); -#ifndef GMIME24 +#ifndef GMIME24 internet_address_list_destroy (addrs); #else g_object_unref (addrs); @@ -990,8 +1004,8 @@ lua_task_get_from_headers (lua_State *L) 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); + if (task) { lua_ip_push (L, &task->from_addr); } @@ -1020,8 +1034,8 @@ lua_task_get_from_ip_num (lua_State *L) static gint lua_task_get_client_ip_num (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - + struct rspamd_task *task = lua_check_task (L); + if (task) { lua_ip_push (L, &task->client_addr); } @@ -1035,8 +1049,8 @@ lua_task_get_client_ip_num (lua_State *L) 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); + if (task) { if (task->helo != NULL) { lua_pushstring (L, (gchar *)task->helo); @@ -1051,8 +1065,8 @@ lua_task_get_helo (lua_State *L) static gint lua_task_set_helo (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *new_helo; + struct rspamd_task *task = lua_check_task (L); + const gchar *new_helo; if (task) { new_helo = luaL_checkstring (L, 2); @@ -1067,7 +1081,7 @@ lua_task_set_helo (lua_State *L) 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); if (task) { if (task->hostname != NULL) { @@ -1097,13 +1111,14 @@ lua_task_get_hostname (lua_State *L) static gint lua_task_set_hostname (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *new_hostname; + struct rspamd_task *task = lua_check_task (L); + const gchar *new_hostname; if (task) { new_hostname = luaL_checkstring (L, 2); if (new_hostname) { - task->hostname = rspamd_mempool_strdup (task->task_pool, new_hostname); + task->hostname = rspamd_mempool_strdup (task->task_pool, + new_hostname); } } @@ -1113,10 +1128,10 @@ lua_task_set_hostname (lua_State *L) static gint lua_task_get_images (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - gint i = 1; - GList *cur; - struct rspamd_image **pimg; + struct rspamd_task *task = lua_check_task (L); + gint i = 1; + GList *cur; + struct rspamd_image **pimg; if (task) { cur = task->images; @@ -1138,12 +1153,15 @@ lua_task_get_images (lua_State *L) } static inline gboolean -lua_push_symbol_result (lua_State *L, struct rspamd_task *task, struct metric *metric, const gchar *symbol) +lua_push_symbol_result (lua_State *L, + struct rspamd_task *task, + struct metric *metric, + const gchar *symbol) { - struct metric_result *metric_res; - struct symbol *s; - gint j; - GList *opt; + struct metric_result *metric_res; + struct symbol *s; + gint j; + GList *opt; metric_res = g_hash_table_lookup (task->results, metric->name); if (metric_res) { @@ -1178,12 +1196,12 @@ lua_push_symbol_result (lua_State *L, struct rspamd_task *task, struct metric *m static gint lua_task_get_symbol (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *symbol; - struct metric *metric; - GList *cur = NULL, *metric_list; - gboolean found = FALSE; - gint i = 1; + struct rspamd_task *task = lua_check_task (L); + const gchar *symbol; + struct metric *metric; + GList *cur = NULL, *metric_list; + gboolean found = FALSE; + gint i = 1; symbol = luaL_checkstring (L, 2); @@ -1224,8 +1242,8 @@ lua_task_get_symbol (lua_State *L) static gint lua_task_get_date (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - time_t task_time; + struct rspamd_task *task = lua_check_task (L); + time_t task_time; if (task != NULL) { /* Get GMT date and store it to time_t */ @@ -1242,7 +1260,7 @@ lua_task_get_date (lua_State *L) 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); if (task != NULL && task->message_id != NULL) { lua_pushstring (L, task->message_id); @@ -1257,7 +1275,7 @@ lua_task_get_message_id (lua_State *L) 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); if (task != NULL) { lua_newtable (L); @@ -1279,13 +1297,13 @@ lua_task_get_timeval (lua_State *L) static gint lua_task_learn_statfile (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *symbol; - struct rspamd_classifier_config *cl; - GTree *tokens; - struct rspamd_statfile_config *st; - stat_file_t *statfile; - struct classifier_ctx *ctx; + struct rspamd_task *task = lua_check_task (L); + const gchar *symbol; + struct rspamd_classifier_config *cl; + GTree *tokens; + struct rspamd_statfile_config *st; + stat_file_t *statfile; + struct classifier_ctx *ctx; symbol = luaL_checkstring (L, 2); @@ -1297,13 +1315,17 @@ lua_task_learn_statfile (lua_State *L) return 1; } ctx = cl->classifier->init_func (task->task_pool, cl); - if ((tokens = g_hash_table_lookup (task->tokens, cl->tokenizer)) == NULL) { + if ((tokens = + g_hash_table_lookup (task->tokens, cl->tokenizer)) == NULL) { msg_warn ("no tokens found learn failed!"); lua_pushboolean (L, FALSE); return 1; } - statfile = get_statfile_by_symbol (task->worker->srv->statfile_pool, ctx->cfg, - symbol, &st, TRUE); + statfile = get_statfile_by_symbol (task->worker->srv->statfile_pool, + ctx->cfg, + symbol, + &st, + TRUE); if (statfile == NULL) { msg_warn ("opening statfile failed!"); @@ -1311,7 +1333,14 @@ lua_task_learn_statfile (lua_State *L) return 1; } - cl->classifier->learn_func (ctx, task->worker->srv->statfile_pool, symbol, tokens, TRUE, NULL, 1., NULL); + cl->classifier->learn_func (ctx, + task->worker->srv->statfile_pool, + symbol, + tokens, + TRUE, + NULL, + 1., + NULL); maybe_write_binlog (ctx->cfg, st, statfile, tokens); lua_pushboolean (L, TRUE); } @@ -1322,20 +1351,23 @@ lua_task_learn_statfile (lua_State *L) static gint lua_task_get_metric_score (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *metric_name; - struct metric_result *metric_res; + struct rspamd_task *task = lua_check_task (L); + const gchar *metric_name; + struct metric_result *metric_res; metric_name = luaL_checkstring (L, 2); if (task && metric_name) { - if ((metric_res = g_hash_table_lookup (task->results, metric_name)) != NULL) { + if ((metric_res = + g_hash_table_lookup (task->results, metric_name)) != NULL) { lua_newtable (L); lua_pushnumber (L, metric_res->score); lua_rawseti (L, -2, 1); - lua_pushnumber (L, metric_res->metric->actions[METRIC_ACTION_REJECT].score); + lua_pushnumber (L, + metric_res->metric->actions[METRIC_ACTION_REJECT].score); lua_rawseti (L, -2, 2); - lua_pushnumber (L, metric_res->metric->actions[METRIC_ACTION_REJECT].score); + lua_pushnumber (L, + metric_res->metric->actions[METRIC_ACTION_REJECT].score); lua_rawseti (L, -2, 3); } else { @@ -1350,17 +1382,19 @@ lua_task_get_metric_score (lua_State *L) static gint lua_task_get_metric_action (lua_State *L) { - struct rspamd_task *task = lua_check_task (L); - const gchar *metric_name; - struct metric_result *metric_res; - enum rspamd_metric_action action; + struct rspamd_task *task = lua_check_task (L); + const gchar *metric_name; + struct metric_result *metric_res; + enum rspamd_metric_action action; metric_name = luaL_checkstring (L, 2); if (task && metric_name) { - if ((metric_res = g_hash_table_lookup (task->results, metric_name)) != NULL) { + if ((metric_res = + g_hash_table_lookup (task->results, metric_name)) != NULL) { action = check_metric_action (metric_res->score, - metric_res->metric->actions[METRIC_ACTION_REJECT].score, metric_res->metric); + metric_res->metric->actions[METRIC_ACTION_REJECT].score, + metric_res->metric); lua_pushstring (L, str_action_metric (action)); } else { @@ -1377,7 +1411,7 @@ lua_task_get_metric_action (lua_State *L) static gint lua_textpart_get_content (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); + struct mime_text_part *part = lua_check_textpart (L); if (part == NULL || part->is_empty) { lua_pushnil (L); @@ -1392,7 +1426,7 @@ lua_textpart_get_content (lua_State * L) static gint lua_textpart_get_length (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); + struct mime_text_part *part = lua_check_textpart (L); if (part == NULL) { lua_pushnil (L); @@ -1412,7 +1446,7 @@ lua_textpart_get_length (lua_State * L) static gint lua_textpart_is_empty (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); + struct mime_text_part *part = lua_check_textpart (L); if (part == NULL) { lua_pushnil (L); @@ -1427,7 +1461,7 @@ lua_textpart_is_empty (lua_State * L) static gint lua_textpart_is_html (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); + struct mime_text_part *part = lua_check_textpart (L); if (part == NULL) { lua_pushnil (L); @@ -1442,106 +1476,108 @@ lua_textpart_is_html (lua_State * L) static gint lua_textpart_get_fuzzy (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); + struct mime_text_part *part = lua_check_textpart (L); if (part == NULL || part->is_empty) { lua_pushnil (L); return 1; } - lua_pushlstring (L, part->fuzzy->hash_pipe, sizeof (part->fuzzy->hash_pipe)); + lua_pushlstring (L, part->fuzzy->hash_pipe, + sizeof (part->fuzzy->hash_pipe)); return 1; } static gint lua_textpart_get_language (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L); - static const gchar languages[][4] = { - "", /* G_UNICODE_SCRIPT_COMMON */ - "", /* G_UNICODE_SCRIPT_INHERITED */ - "ar", /* G_UNICODE_SCRIPT_ARABIC */ - "hy", /* G_UNICODE_SCRIPT_ARMENIAN */ - "bn", /* G_UNICODE_SCRIPT_BENGALI */ - /* Used primarily in Taiwan, but not part of the standard - * zh-tw orthography */ - "", /* G_UNICODE_SCRIPT_BOPOMOFO */ - "chr", /* G_UNICODE_SCRIPT_CHEROKEE */ - "cop", /* G_UNICODE_SCRIPT_COPTIC */ - "ru", /* G_UNICODE_SCRIPT_CYRILLIC */ - /* Deseret was used to write English */ - "", /* G_UNICODE_SCRIPT_DESERET */ - "hi", /* G_UNICODE_SCRIPT_DEVANAGARI */ - "am", /* G_UNICODE_SCRIPT_ETHIOPIC */ - "ka", /* G_UNICODE_SCRIPT_GEORGIAN */ - "", /* G_UNICODE_SCRIPT_GOTHIC */ - "el", /* G_UNICODE_SCRIPT_GREEK */ - "gu", /* G_UNICODE_SCRIPT_GUJARATI */ - "pa", /* G_UNICODE_SCRIPT_GURMUKHI */ - "", /* G_UNICODE_SCRIPT_HAN */ - "ko", /* G_UNICODE_SCRIPT_HANGUL */ - "he", /* G_UNICODE_SCRIPT_HEBREW */ - "ja", /* G_UNICODE_SCRIPT_HIRAGANA */ - "kn", /* G_UNICODE_SCRIPT_KANNADA */ - "ja", /* G_UNICODE_SCRIPT_KATAKANA */ - "km", /* G_UNICODE_SCRIPT_KHMER */ - "lo", /* G_UNICODE_SCRIPT_LAO */ - "en", /* G_UNICODE_SCRIPT_LATIN */ - "ml", /* G_UNICODE_SCRIPT_MALAYALAM */ - "mn", /* G_UNICODE_SCRIPT_MONGOLIAN */ - "my", /* G_UNICODE_SCRIPT_MYANMAR */ - /* Ogham was used to write old Irish */ - "", /* G_UNICODE_SCRIPT_OGHAM */ - "", /* G_UNICODE_SCRIPT_OLD_ITALIC */ - "or", /* G_UNICODE_SCRIPT_ORIYA */ - "", /* G_UNICODE_SCRIPT_RUNIC */ - "si", /* G_UNICODE_SCRIPT_SINHALA */ - "syr", /* G_UNICODE_SCRIPT_SYRIAC */ - "ta", /* G_UNICODE_SCRIPT_TAMIL */ - "te", /* G_UNICODE_SCRIPT_TELUGU */ - "dv", /* G_UNICODE_SCRIPT_THAANA */ - "th", /* G_UNICODE_SCRIPT_THAI */ - "bo", /* G_UNICODE_SCRIPT_TIBETAN */ - "iu", /* G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL */ - "", /* G_UNICODE_SCRIPT_YI */ - "tl", /* G_UNICODE_SCRIPT_TAGALOG */ - /* Phillipino languages/scripts */ - "hnn", /* G_UNICODE_SCRIPT_HANUNOO */ - "bku", /* G_UNICODE_SCRIPT_BUHID */ - "tbw", /* G_UNICODE_SCRIPT_TAGBANWA */ - - "", /* G_UNICODE_SCRIPT_BRAILLE */ - "", /* G_UNICODE_SCRIPT_CYPRIOT */ - "", /* G_UNICODE_SCRIPT_LIMBU */ - /* Used for Somali (so) in the past */ - "", /* G_UNICODE_SCRIPT_OSMANYA */ - /* The Shavian alphabet was designed for English */ - "", /* G_UNICODE_SCRIPT_SHAVIAN */ - "", /* G_UNICODE_SCRIPT_LINEAR_B */ - "", /* G_UNICODE_SCRIPT_TAI_LE */ - "uga", /* G_UNICODE_SCRIPT_UGARITIC */ - - "", /* G_UNICODE_SCRIPT_NEW_TAI_LUE */ - "bug", /* G_UNICODE_SCRIPT_BUGINESE */ - /* The original script for Old Church Slavonic (chu), later - * written with Cyrillic */ - "", /* G_UNICODE_SCRIPT_GLAGOLITIC */ - /* Used for for Berber (ber), but Arabic script is more common */ - "", /* G_UNICODE_SCRIPT_TIFINAGH */ - "syl", /* G_UNICODE_SCRIPT_SYLOTI_NAGRI */ - "peo", /* G_UNICODE_SCRIPT_OLD_PERSIAN */ - "", /* G_UNICODE_SCRIPT_KHAROSHTHI */ - - "", /* G_UNICODE_SCRIPT_UNKNOWN */ - "", /* G_UNICODE_SCRIPT_BALINESE */ - "", /* G_UNICODE_SCRIPT_CUNEIFORM */ - "", /* G_UNICODE_SCRIPT_PHOENICIAN */ - "", /* G_UNICODE_SCRIPT_PHAGS_PA */ - "nqo" /* G_UNICODE_SCRIPT_NKO */ + struct mime_text_part *part = lua_check_textpart (L); + static const gchar languages[][4] = { + "", /* G_UNICODE_SCRIPT_COMMON */ + "", /* G_UNICODE_SCRIPT_INHERITED */ + "ar", /* G_UNICODE_SCRIPT_ARABIC */ + "hy", /* G_UNICODE_SCRIPT_ARMENIAN */ + "bn", /* G_UNICODE_SCRIPT_BENGALI */ + /* Used primarily in Taiwan, but not part of the standard + * zh-tw orthography */ + "", /* G_UNICODE_SCRIPT_BOPOMOFO */ + "chr", /* G_UNICODE_SCRIPT_CHEROKEE */ + "cop", /* G_UNICODE_SCRIPT_COPTIC */ + "ru", /* G_UNICODE_SCRIPT_CYRILLIC */ + /* Deseret was used to write English */ + "", /* G_UNICODE_SCRIPT_DESERET */ + "hi", /* G_UNICODE_SCRIPT_DEVANAGARI */ + "am", /* G_UNICODE_SCRIPT_ETHIOPIC */ + "ka", /* G_UNICODE_SCRIPT_GEORGIAN */ + "", /* G_UNICODE_SCRIPT_GOTHIC */ + "el", /* G_UNICODE_SCRIPT_GREEK */ + "gu", /* G_UNICODE_SCRIPT_GUJARATI */ + "pa", /* G_UNICODE_SCRIPT_GURMUKHI */ + "", /* G_UNICODE_SCRIPT_HAN */ + "ko", /* G_UNICODE_SCRIPT_HANGUL */ + "he", /* G_UNICODE_SCRIPT_HEBREW */ + "ja", /* G_UNICODE_SCRIPT_HIRAGANA */ + "kn", /* G_UNICODE_SCRIPT_KANNADA */ + "ja", /* G_UNICODE_SCRIPT_KATAKANA */ + "km", /* G_UNICODE_SCRIPT_KHMER */ + "lo", /* G_UNICODE_SCRIPT_LAO */ + "en", /* G_UNICODE_SCRIPT_LATIN */ + "ml", /* G_UNICODE_SCRIPT_MALAYALAM */ + "mn", /* G_UNICODE_SCRIPT_MONGOLIAN */ + "my", /* G_UNICODE_SCRIPT_MYANMAR */ + /* Ogham was used to write old Irish */ + "", /* G_UNICODE_SCRIPT_OGHAM */ + "", /* G_UNICODE_SCRIPT_OLD_ITALIC */ + "or", /* G_UNICODE_SCRIPT_ORIYA */ + "", /* G_UNICODE_SCRIPT_RUNIC */ + "si", /* G_UNICODE_SCRIPT_SINHALA */ + "syr", /* G_UNICODE_SCRIPT_SYRIAC */ + "ta", /* G_UNICODE_SCRIPT_TAMIL */ + "te", /* G_UNICODE_SCRIPT_TELUGU */ + "dv", /* G_UNICODE_SCRIPT_THAANA */ + "th", /* G_UNICODE_SCRIPT_THAI */ + "bo", /* G_UNICODE_SCRIPT_TIBETAN */ + "iu", /* G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL */ + "", /* G_UNICODE_SCRIPT_YI */ + "tl", /* G_UNICODE_SCRIPT_TAGALOG */ + /* Phillipino languages/scripts */ + "hnn", /* G_UNICODE_SCRIPT_HANUNOO */ + "bku", /* G_UNICODE_SCRIPT_BUHID */ + "tbw", /* G_UNICODE_SCRIPT_TAGBANWA */ + + "", /* G_UNICODE_SCRIPT_BRAILLE */ + "", /* G_UNICODE_SCRIPT_CYPRIOT */ + "", /* G_UNICODE_SCRIPT_LIMBU */ + /* Used for Somali (so) in the past */ + "", /* G_UNICODE_SCRIPT_OSMANYA */ + /* The Shavian alphabet was designed for English */ + "", /* G_UNICODE_SCRIPT_SHAVIAN */ + "", /* G_UNICODE_SCRIPT_LINEAR_B */ + "", /* G_UNICODE_SCRIPT_TAI_LE */ + "uga", /* G_UNICODE_SCRIPT_UGARITIC */ + + "", /* G_UNICODE_SCRIPT_NEW_TAI_LUE */ + "bug", /* G_UNICODE_SCRIPT_BUGINESE */ + /* The original script for Old Church Slavonic (chu), later + * written with Cyrillic */ + "", /* G_UNICODE_SCRIPT_GLAGOLITIC */ + /* Used for for Berber (ber), but Arabic script is more common */ + "", /* G_UNICODE_SCRIPT_TIFINAGH */ + "syl", /* G_UNICODE_SCRIPT_SYLOTI_NAGRI */ + "peo", /* G_UNICODE_SCRIPT_OLD_PERSIAN */ + "", /* G_UNICODE_SCRIPT_KHAROSHTHI */ + + "", /* G_UNICODE_SCRIPT_UNKNOWN */ + "", /* G_UNICODE_SCRIPT_BALINESE */ + "", /* G_UNICODE_SCRIPT_CUNEIFORM */ + "", /* G_UNICODE_SCRIPT_PHOENICIAN */ + "", /* G_UNICODE_SCRIPT_PHAGS_PA */ + "nqo" /* G_UNICODE_SCRIPT_NKO */ }; - const gchar *sel; + const gchar *sel; - if (part != NULL && part->script > 0 && part->script < (gint)G_N_ELEMENTS (languages)) { + if (part != NULL && part->script > 0 && part->script < + (gint)G_N_ELEMENTS (languages)) { sel = languages[part->script]; if (*sel != '\0') { lua_pushstring (L, sel); @@ -1556,11 +1592,11 @@ lua_textpart_get_language (lua_State * L) static gint lua_textpart_compare_distance (lua_State * L) { - struct mime_text_part *part = lua_check_textpart (L), *other; - void *ud = luaL_checkudata (L, 2, "rspamd{textpart}"); - gint diff = -1; - GMimeObject *parent; - const GMimeContentType *ct; + struct mime_text_part *part = lua_check_textpart (L), *other; + void *ud = luaL_checkudata (L, 2, "rspamd{textpart}"); + gint diff = -1; + GMimeObject *parent; + const GMimeContentType *ct; luaL_argcheck (L, ud != NULL, 2, "'textpart' expected"); other = ud ? *((struct mime_text_part **)ud) : NULL; @@ -1569,9 +1605,12 @@ lua_textpart_compare_distance (lua_State * L) parent = part->parent; ct = g_mime_object_get_content_type (parent); #ifndef GMIME24 - if (ct == NULL || ! g_mime_content_type_is_type (ct, "multipart", "alternative")) { + if (ct == NULL || + !g_mime_content_type_is_type (ct, "multipart", "alternative")) { #else - if (ct == NULL || ! g_mime_content_type_is_type ((GMimeContentType *)ct, "multipart", "alternative")) { + if (ct == NULL || + !g_mime_content_type_is_type ((GMimeContentType *)ct, "multipart", + "alternative")) { #endif diff = -1; @@ -1579,20 +1618,22 @@ lua_textpart_compare_distance (lua_State * L) else { if (!part->is_empty && !other->is_empty) { if (part->diff_str != NULL && other->diff_str != NULL) { - diff = compare_diff_distance (part->diff_str, other->diff_str); + diff = compare_diff_distance (part->diff_str, + other->diff_str); } else { diff = fuzzy_compare_parts (part, other); } } - else if ((part->is_empty && !other->is_empty) || (!part->is_empty && other->is_empty)) { + else if ((part->is_empty && + !other->is_empty) || (!part->is_empty && other->is_empty)) { /* Empty and non empty parts are different */ diff = 0; } } } else { - diff = -1; + diff = -1; } @@ -1606,7 +1647,7 @@ lua_textpart_compare_distance (lua_State * L) static gint lua_mimepart_get_content (lua_State * L) { - struct mime_part *part = lua_check_mimepart (L); + struct mime_part *part = lua_check_mimepart (L); if (part == NULL) { lua_pushnil (L); @@ -1621,7 +1662,7 @@ lua_mimepart_get_content (lua_State * L) static gint lua_mimepart_get_length (lua_State * L) { - struct mime_part *part = lua_check_mimepart (L); + struct mime_part *part = lua_check_mimepart (L); if (part == NULL) { lua_pushnil (L); @@ -1636,7 +1677,7 @@ lua_mimepart_get_length (lua_State * L) static gint lua_mimepart_get_type (lua_State * L) { - struct mime_part *part = lua_check_mimepart (L); + struct mime_part *part = lua_check_mimepart (L); if (part == NULL) { lua_pushnil (L); @@ -1657,7 +1698,7 @@ lua_mimepart_get_type (lua_State * L) static gint lua_mimepart_get_filename (lua_State * L) { - struct mime_part *part = lua_check_mimepart (L); + struct mime_part *part = lua_check_mimepart (L); if (part == NULL || part->filename == NULL) { lua_pushnil (L); @@ -1673,7 +1714,7 @@ lua_mimepart_get_filename (lua_State * L) static gint lua_image_get_width (lua_State *L) { - struct rspamd_image *img = lua_check_image (L); + struct rspamd_image *img = lua_check_image (L); if (img != NULL) { lua_pushnumber (L, img->width); @@ -1687,7 +1728,7 @@ lua_image_get_width (lua_State *L) static gint lua_image_get_height (lua_State *L) { - struct rspamd_image *img = lua_check_image (L); + struct rspamd_image *img = lua_check_image (L); if (img != NULL) { lua_pushnumber (L, img->height); @@ -1702,7 +1743,7 @@ lua_image_get_height (lua_State *L) static gint lua_image_get_type (lua_State *L) { - struct rspamd_image *img = lua_check_image (L); + struct rspamd_image *img = lua_check_image (L); if (img != NULL) { lua_pushstring (L, image_type_str (img->type)); @@ -1717,7 +1758,7 @@ lua_image_get_type (lua_State *L) static gint lua_image_get_size (lua_State *L) { - struct rspamd_image *img = lua_check_image (L); + struct rspamd_image *img = lua_check_image (L); if (img != NULL) { lua_pushinteger (L, img->data->len); @@ -1732,7 +1773,7 @@ lua_image_get_size (lua_State *L) static gint lua_image_get_filename (lua_State *L) { - struct rspamd_image *img = lua_check_image (L); + struct rspamd_image *img = lua_check_image (L); if (img != NULL && img->filename != NULL) { lua_pushstring (L, img->filename); @@ -1748,7 +1789,7 @@ lua_image_get_filename (lua_State *L) static gint lua_url_get_length (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushinteger (L, strlen (struri (url))); @@ -1762,7 +1803,7 @@ lua_url_get_length (lua_State *L) static gint lua_url_get_host (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushlstring (L, url->host, url->hostlen); @@ -1776,7 +1817,7 @@ lua_url_get_host (lua_State *L) static gint lua_url_get_user (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushlstring (L, url->user, url->userlen); @@ -1791,7 +1832,7 @@ lua_url_get_user (lua_State *L) static gint lua_url_get_path (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushlstring (L, url->data, url->datalen); @@ -1806,7 +1847,7 @@ lua_url_get_path (lua_State *L) static gint lua_url_get_text (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushstring (L, struri (url)); @@ -1821,7 +1862,7 @@ lua_url_get_text (lua_State *L) static gint lua_url_is_phished (lua_State *L) { - struct uri *url = lua_check_url (L); + struct uri *url = lua_check_url (L); if (url != NULL) { lua_pushboolean (L, url->is_phished); @@ -1836,7 +1877,7 @@ lua_url_is_phished (lua_State *L) static gint lua_url_get_phished (lua_State *L) { - struct uri **purl, *url = lua_check_url (L); + struct uri **purl, *url = lua_check_url (L); if (url) { if (url->is_phished && url->phished_url != NULL) { |