Browse Source

implement _mime_decode_message(), but with a lot of code duplication. Not optimal.

MIME-12
Roker 2 years ago
parent
commit
67dfd353ae
1 changed files with 35 additions and 0 deletions
  1. +35
    -0
      src/pEpEngine_mime.cc

+ 35
- 0
src/pEpEngine_mime.cc View File

@ -6,6 +6,7 @@
#define _EXPORT_PEP_ENGINE_DLL
#include <pEp/message.h>
#include "pEpMIME.hh"
#include "pEpMIME_internal.hh"
// function interface for pEp engine
// link this to use pEp MIME with C code
@ -43,6 +44,40 @@ extern "C"
}
DYNAMIC_API PEP_STATUS _mime_decode_message(
const char *mimetext,
size_t size,
message **msg,
bool* raise_msg_attachment
)
{
assert(msg);
assert(mimetext);
if (!(msg && mimetext))
return PEP_ILLEGAL_VALUE;
PEP_STATUS status = PEP_STATUS_OK;
*msg = nullptr;
try{
message* m = pEpMIME::parse_message(mimetext, size);
if(m)
{
*msg = m;
stringpair_list_t* forwarded = stringpair_list_find(m->opt_fields, pEpMIME::Pseudo_Header_Forwarded.data());
*raise_msg_attachment = (forwarded && forwarded->value && forwarded->value->value==std::string{"no"});
}else{
status = PEP_OUT_OF_MEMORY;
}
}catch(...)
{
status = PEP_UNKNOWN_ERROR;
}
return status;
}
PEP_STATUS _mime_encode_message_internal(
const message * msg,
bool omit_fields,


Loading…
Cancel
Save