#include "general.h"
+struct _rspamd_lua_text {
+ const char *start;
+ unsigned int len;
+ unsigned int flags;
+};
+
#define torch_Storage_(NAME) TH_CONCAT_4(torch_,Real,Storage_,NAME)
#define THFile_readRealRaw TH_CONCAT_3(THFile_read, Real, Raw)
#define THFile_writeRealRaw TH_CONCAT_3(THFile_write, Real, Raw)
}
#endif
+static int torch_Storage_(text)(lua_State *L)
+{
+ THStorage *storage = luaT_checkudata(L, 1, torch_Storage);
+ struct _rspamd_lua_text *t;
+
+ if(lua_type(L, -1) == LUA_TUSERDATA)
+ {
+ t = lua_touserdata(L, -1);
+ THStorage_(resize)(storage, t->len);
+ memmove(storage->data, t->start, t->len);
+ lua_settop(L, 1);
+ }
+ else {
+ t = lua_newuserdata (L, sizeof (*t));
+ t->start = (const char *)storage->data;
+ t->len = t->len;
+ t->flags = 0;
+ }
+
+ return 1; /* either storage or string */
+}
+
static int torch_Storage_(totable)(lua_State *L)
{
THStorage *storage = luaT_checkudata(L, 1, torch_Storage);
{"totable", torch_Storage_(totable)},
{"write", torch_Storage_(write)},
{"read", torch_Storage_(read)},
+ {"text", torch_Storage_(text)},
#if defined(TH_REAL_IS_CHAR) || defined(TH_REAL_IS_BYTE)
{"string", torch_Storage_(string)},
#endif