diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-25 20:15:29 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-25 20:15:29 +0400 |
commit | 59822ebf58a3bf9f0a3bb97150206013be3b43d7 (patch) | |
tree | d08236df32ec8742c3ca2b6097de0977aa893ace /src/lua/lua_task.c | |
parent | 671bbfa9cc85a625df33d6384a3179ce076765b9 (diff) | |
download | rspamd-59822ebf58a3bf9f0a3bb97150206013be3b43d7.tar.gz rspamd-59822ebf58a3bf9f0a3bb97150206013be3b43d7.zip |
* Add ability to extract filename and size of images from lua
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index b18cfc21f..cb9433d5e 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -109,11 +109,15 @@ static const struct luaL_reg textpartlib_m[] = { LUA_FUNCTION_DEF (image, get_width); LUA_FUNCTION_DEF (image, get_height); LUA_FUNCTION_DEF (image, get_type); +LUA_FUNCTION_DEF (image, get_filename); +LUA_FUNCTION_DEF (image, get_size); static const struct luaL_reg imagelib_m[] = { LUA_INTERFACE_DEF (image, get_width), LUA_INTERFACE_DEF (image, get_height), LUA_INTERFACE_DEF (image, get_type), + LUA_INTERFACE_DEF (image, get_filename), + LUA_INTERFACE_DEF (image, get_size), {"__tostring", lua_class_tostring}, {NULL, NULL} }; @@ -885,6 +889,36 @@ lua_image_get_type (lua_State *L) return 1; } +static int +lua_image_get_size (lua_State *L) +{ + struct rspamd_image *img = lua_check_image (L); + + if (img != NULL) { + lua_pushinteger (L, img->data->len); + } + else { + lua_pushnil (L); + } + + return 1; +} + +static int +lua_image_get_filename (lua_State *L) +{ + struct rspamd_image *img = lua_check_image (L); + + if (img != NULL && img->filename != NULL) { + lua_pushstring (L, img->filename); + } + else { + lua_pushnil (L); + } + + return 1; +} + /* Init part */ int luaopen_task (lua_State * L) |