]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_task: Add topointer method
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Feb 2019 17:06:03 +0000 (17:06 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Feb 2019 17:06:03 +0000 (17:06 +0000)
src/libserver/dkim.h
src/lua/lua_task.c

index d57c923bbe780bdaea875913983554656df11d3a..fe2b4cc4e1c19e3aefe15c382b6666812f356359 100644 (file)
@@ -101,8 +101,6 @@ typedef struct rspamd_dkim_sign_context_s rspamd_dkim_sign_context_t;
 
 struct rspamd_dkim_key_s;
 typedef struct rspamd_dkim_key_s rspamd_dkim_key_t;
-
-struct rspamd_dkim_key_s;
 typedef struct rspamd_dkim_key_s rspamd_dkim_sign_key_t;
 
 struct rspamd_task;
index c4e1b6d92a60ef6879615bfd574cb3a5d0aaecdf..90cb1f6898f34da60284d02180492e2792d028d4 100644 (file)
@@ -986,6 +986,13 @@ LUA_FUNCTION_DEF (task, get_stat_tokens);
  */
 LUA_FUNCTION_DEF (task, lookup_words);
 
+/**
+ * @method task:topointer()
+ *
+ * Returns raw C pointer (lightuserdata) associated with task
+ */
+LUA_FUNCTION_DEF (task, topointer);
+
 static const struct luaL_reg tasklib_f[] = {
        LUA_INTERFACE_DEF (task, load_from_file),
        LUA_INTERFACE_DEF (task, load_from_string),
@@ -1091,6 +1098,7 @@ static const struct luaL_reg tasklib_m[] = {
        LUA_INTERFACE_DEF (task, get_stat_tokens),
        LUA_INTERFACE_DEF (task, get_meta_words),
        LUA_INTERFACE_DEF (task, lookup_words),
+       LUA_INTERFACE_DEF (task, topointer),
        {"__tostring", rspamd_lua_class_tostring},
        {NULL, NULL}
 };
@@ -5434,6 +5442,22 @@ lua_task_lookup_words (lua_State *L)
        return 1;
 }
 
+static gint
+lua_task_topointer (lua_State *L)
+{
+       LUA_TRACE_POINT;
+       struct rspamd_task *task = lua_check_task (L, 1);
+
+       if (task) {
+               lua_pushlightuserdata (L, task);
+       }
+       else {
+               return luaL_error (L, "invalid arguments");
+       }
+
+       return 1;
+}
+
 
 /* Image functions */
 static gint