summaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-07 11:48:26 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-07 11:49:17 +0000
commitf05496beabff912e4ff87c21a34bc4f2884fc33b (patch)
tree31659d66a318241587b3fd1284895012fcbb7e5c /src/lua
parenta87070a16587cd02f3c1d3f930186a0e957a098a (diff)
downloadrspamd-f05496beabff912e4ff87c21a34bc4f2884fc33b.tar.gz
rspamd-f05496beabff912e4ff87c21a34bc4f2884fc33b.zip
[Feature] Allow to extract CTE in Lua API
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_mimepart.c26
1 files changed, 25 insertions, 1 deletions
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),
@@ -689,6 +698,21 @@ lua_mimepart_get_type (lua_State * L)
}
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)
{
struct rspamd_mime_part *part = lua_check_mimepart (L);