aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-13 11:22:03 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-13 11:22:03 +0100
commit78c29d057daaadc2eb56ef597c0f3dc3c4f31760 (patch)
tree4a7ad032004ec631befcb79ab74f03e8182b7707
parente26f428b72de0762a5dc6421941f9e59dba3be01 (diff)
downloadrspamd-78c29d057daaadc2eb56ef597c0f3dc3c4f31760.tar.gz
rspamd-78c29d057daaadc2eb56ef597c0f3dc3c4f31760.zip
Allow to push raw pointer from the text boxed type.
-rw-r--r--src/lua/lua_task.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 1789fbe24..1b4f626e1 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