]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Remove stupid lua_message module.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Sep 2014 16:59:42 +0000 (17:59 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Sep 2014 16:59:42 +0000 (17:59 +0100)
src/lua/CMakeLists.txt
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_message.c [deleted file]

index f05da4985e6bec9af1834e62581c6af0d6c788ed..5e2df241956564751c4f56ccf84c7909abf750e7 100644 (file)
@@ -1,7 +1,6 @@
 # Lua support makefile
 SET(LUASRC                       lua_common.c
                                          lua_task.c
-                                         lua_message.c
                                          lua_config.c
                                          lua_classifier.c
                                          lua_cfg_file.c
index 17b284e0c509648399c25a0526e3acb7429bffe5..691bd34455c7d1434b9f933ac618bd3ea80ea875 100644 (file)
@@ -300,7 +300,6 @@ rspamd_lua_init (struct rspamd_config *cfg)
        luaopen_mimepart (L);
        luaopen_image (L);
        luaopen_url (L);
-       luaopen_message (L);
        luaopen_classifier (L);
        luaopen_statfile (L);
        luaopen_glib_regexp (L);
index 6594cdc2b565435c761ec66ddce3e0ecfedab408..f67d271d6ead768ac03fac2d984517c7818d33f3 100644 (file)
@@ -149,7 +149,6 @@ struct rspamd_lua_ip {
  */
 void rspamd_lua_add_preload (lua_State *L, const gchar *name, lua_CFunction func);
 
-void luaopen_message (lua_State *L);
 void luaopen_task (lua_State *L);
 void luaopen_config (lua_State *L);
 void luaopen_metric (lua_State *L);
diff --git a/src/lua/lua_message.c b/src/lua/lua_message.c
deleted file mode 100644 (file)
index f40d646..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2009-2012, Vsevolod Stakhov
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "lua_common.h"
-#include "message.h"
-
-#define LUA_GMIME_BRIDGE_GET(class, name, mime_class)                                   \
-       static gint                                                                             \
-       lua_ ## class ## _ ## name (lua_State * L)                                                      \
-       {                                                                                       \
-               GMime ## mime_class * obj = lua_check_ ## class (L);                                      \
-               if (obj != NULL) {                                                                  \
-                       lua_pushstring (L, g_mime_ ## class ## _ ## name (obj));                               \
-               }                                                                                   \
-               else {                                                                              \
-                       lua_pushnil (L);                                                                \
-               }                                                                                   \
-               return 1;                                                                           \
-       }
-
-#define LUA_GMIME_BRIDGE_SET(class, name, mime_class)                                   \
-       static gint                                                                             \
-       lua_ ## class ## _ ## name (lua_State * L)                                                      \
-       {                                                                                       \
-               const gchar *str;                                                                   \
-               GMime ## mime_class * obj = lua_check_ ## class (L);                                      \
-               if (obj != NULL) {                                                                  \
-                       str = luaL_checkstring (L, 2);                                                  \
-                       g_mime_ ## class ## _ ## name (obj, str);                                              \
-               }                                                                                   \
-               else {                                                                              \
-                       lua_pushnil (L);                                                                \
-               }                                                                                   \
-               return 1;                                                                           \
-       }
-
-/*  Message methods */
-LUA_FUNCTION_DEF (message, get_subject);
-LUA_FUNCTION_DEF (message, set_subject);
-LUA_FUNCTION_DEF (message, get_message_id);
-LUA_FUNCTION_DEF (message, set_message_id);
-LUA_FUNCTION_DEF (message, get_sender);
-LUA_FUNCTION_DEF (message, set_sender);
-LUA_FUNCTION_DEF (message, get_reply_to);
-LUA_FUNCTION_DEF (message, set_reply_to);
-LUA_FUNCTION_DEF (message, get_header);
-LUA_FUNCTION_DEF (message, get_header_strong);
-LUA_FUNCTION_DEF (message, set_header);
-LUA_FUNCTION_DEF (message, get_date);
-
-static const struct luaL_reg msglib_m[] = {
-       LUA_INTERFACE_DEF (message, get_subject),
-       LUA_INTERFACE_DEF (message, set_subject),
-       LUA_INTERFACE_DEF (message, get_message_id),
-       LUA_INTERFACE_DEF (message, set_message_id),
-       LUA_INTERFACE_DEF (message, get_sender),
-       LUA_INTERFACE_DEF (message, set_sender),
-       LUA_INTERFACE_DEF (message, get_reply_to),
-       LUA_INTERFACE_DEF (message, set_reply_to),
-       LUA_INTERFACE_DEF (message, get_header),
-       LUA_INTERFACE_DEF (message, get_header_strong),
-       LUA_INTERFACE_DEF (message, set_header),
-       LUA_INTERFACE_DEF (message, get_date),
-       {"__tostring", rspamd_lua_class_tostring},
-       {NULL, NULL}
-};
-
-
-
-static GMimeMessage *
-lua_check_message (lua_State * L)
-{
-       void *ud = luaL_checkudata (L, 1, "rspamd{message}");
-       luaL_argcheck (L, ud != NULL, 1, "'message' expected");
-       return ud ? *((GMimeMessage **) ud) : NULL;
-}
-
-
-/*** Message interface ***/
-
-LUA_GMIME_BRIDGE_GET (message, get_subject, Message)
-LUA_GMIME_BRIDGE_SET (message, set_subject, Message)
-LUA_GMIME_BRIDGE_GET (message, get_message_id, Message)
-LUA_GMIME_BRIDGE_SET (message, set_message_id, Message)
-LUA_GMIME_BRIDGE_GET (message, get_sender, Message)
-LUA_GMIME_BRIDGE_SET (message, set_sender, Message)
-LUA_GMIME_BRIDGE_GET (message, get_reply_to, Message)
-LUA_GMIME_BRIDGE_SET (message, set_reply_to, Message)
-
-static gint
-lua_message_get_header_common (lua_State * L, gboolean strong)
-{
-       const gchar *headern;
-       GMimeMessage *obj = lua_check_message (L);
-       GList *res = NULL, *cur;
-       gint i = 1;
-
-       if (obj != NULL) {
-               headern = luaL_checkstring (L, 2);
-               if (headern) {
-                       res = message_get_header (NULL, obj, headern, strong);
-                       if (res) {
-                               cur = res;
-                               lua_newtable (L);
-                               while (cur) {
-                                       lua_pushstring (L, (const gchar *)cur->data);
-                                       lua_rawseti (L, -2, i++);
-                                       g_free (cur->data);
-                                       cur = g_list_next (cur);
-                               }
-                               g_list_free (res);
-                       }
-                       else {
-                               lua_pushnil (L);
-                       }
-               }
-               else {
-                       lua_pushnil (L);
-               }
-       }
-       else {
-               lua_pushnil (L);
-       }
-
-       return 1;
-}
-
-static gint
-lua_message_get_header (lua_State * L)
-{
-       return lua_message_get_header_common (L, FALSE);
-}
-
-static gint
-lua_message_get_header_strong (lua_State * L)
-{
-       return lua_message_get_header_common (L, TRUE);
-}
-
-static gint
-lua_message_set_header (lua_State * L)
-{
-       const gchar *headern, *headerv;
-       GMimeMessage *obj = lua_check_message (L);
-
-       if (obj != NULL) {
-               headern = luaL_checkstring (L, 2);
-               headerv = luaL_checkstring (L, 3);
-               if (headern && headerv) {
-                       message_set_header (obj, headern, headerv);
-               }
-               else {
-                       lua_pushnil (L);
-               }
-       }
-       else {
-               lua_pushnil (L);
-       }
-
-       return 1;
-}
-
-static gint
-lua_message_get_date (lua_State * L)
-{
-       GMimeMessage *obj = lua_check_message (L);
-       time_t msg_time;
-       int offset;
-
-       if (obj != NULL) {
-               g_mime_message_get_date (obj, &msg_time, &offset);
-               lua_pushnumber (L, msg_time);
-       }
-       else {
-               lua_pushnil (L);
-       }
-
-       return 1;
-}
-
-void
-luaopen_message (lua_State * L)
-{
-       rspamd_lua_new_class (L, "rspamd{message}", msglib_m);
-       lua_pop (L, 1);                      /* remove metatable from stack */
-}