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}
};
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)
mime_part->type = type;
mime_part->content = part_content;
mime_part->parent = task->parser_parent_part;
+ mime_part->filename = g_mime_part_get_filename (GMIME_PART (part));
/* Extract checksums for some types */
if (g_mime_content_type_is_type (type, "image", "*") && part_content->len > 0) {
mime_part->checksum = g_compute_checksum_for_data (G_CHECKSUM_MD5, part_content->data, part_content->len);