From: Vsevolod Stakhov Date: Wed, 13 May 2015 10:22:03 +0000 (+0100) Subject: Allow to push raw pointer from the text boxed type. X-Git-Tag: 0.9.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78c29d057daaadc2eb56ef597c0f3dc3c4f31760;p=thirdparty%2Frspamd.git Allow to push raw pointer from the text boxed type. --- diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 1789fbe24d..1b4f626e1b 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -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