]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Allow to push raw pointer from the text boxed type.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 May 2015 10:22:03 +0000 (11:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 May 2015 10:22:03 +0000 (11:22 +0100)
src/lua/lua_task.c

index 1789fbe24d7d6f70741f012853303c8d650bb22b..1b4f626e1b768988faf716d29b132486ecd9a25e 100644 (file)
@@ -520,10 +520,12 @@ static const struct luaL_reg imagelib_m[] = {
 /* Blob methods */
 LUA_FUNCTION_DEF (text, len);
 LUA_FUNCTION_DEF (text, str);
+LUA_FUNCTION_DEF (text, ptr);
 
 static const struct luaL_reg textlib_m[] = {
        LUA_INTERFACE_DEF (text, len),
        LUA_INTERFACE_DEF (text, str),
+       LUA_INTERFACE_DEF (text, ptr),
        {"__tostring", lua_text_str},
        {NULL, NULL}
 };
@@ -1982,6 +1984,21 @@ lua_text_str (lua_State *L)
        return 1;
 }
 
+static gint
+lua_text_ptr (lua_State *L)
+{
+       struct rspamd_lua_text *t = lua_check_text (L, 1);
+
+       if (t != NULL) {
+               lua_pushlightuserdata (L, (gpointer)t->start);
+       }
+       else {
+               lua_pushnil (L);
+       }
+
+       return 1;
+}
+
 /* Init part */
 
 static gint