From f05496beabff912e4ff87c21a34bc4f2884fc33b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 7 Mar 2017 11:48:26 +0000 Subject: [PATCH] [Feature] Allow to extract CTE in Lua API --- src/lua/lua_mimepart.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index 1ff3dbd58..8a9fb85e1 100644 --- a/src/lua/lua_mimepart.c +++ b/src/lua/lua_mimepart.c @@ -226,9 +226,17 @@ LUA_FUNCTION_DEF (mimepart, get_length); /*** * @method mime_part:get_type() * Extract content-type string of the mime part - * @return {string} content type in form 'type/subtype' + * @return {string,string} content type in form 'type','subtype' */ LUA_FUNCTION_DEF (mimepart, get_type); + +/*** + * @method mime_part:get_cte() + * Extract content-transfer-encoding for a part + * @return {string} content transfer encoding (e.g. `base64` or `7bit`) + */ +LUA_FUNCTION_DEF (mimepart, get_cte); + /*** * @method mime_part:get_filename() * Extract filename associated with mime part if it is an attachement @@ -304,6 +312,7 @@ static const struct luaL_reg mimepartlib_m[] = { LUA_INTERFACE_DEF (mimepart, get_content), LUA_INTERFACE_DEF (mimepart, get_length), LUA_INTERFACE_DEF (mimepart, get_type), + LUA_INTERFACE_DEF (mimepart, get_cte), LUA_INTERFACE_DEF (mimepart, get_filename), LUA_INTERFACE_DEF (mimepart, get_header), LUA_INTERFACE_DEF (mimepart, get_header_raw), @@ -688,6 +697,21 @@ lua_mimepart_get_type (lua_State * L) return 2; } +static gint +lua_mimepart_get_cte (lua_State * L) +{ + struct rspamd_mime_part *part = lua_check_mimepart (L); + + if (part == NULL) { + lua_pushnil (L); + return 1; + } + + lua_pushstring (L, rspamd_cte_to_string (part->cte)); + + return 1; +} + static gint lua_mimepart_get_filename (lua_State * L) { -- 2.39.5