p≡p MIME library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.8 KiB

  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. // This is the main header for pEp MIME, a C++ library to parse & generate MIME-compliant messages
  4. // There exists a C wrapper that is compatible to <pEp/mime.h>
  5. #ifndef PEP_MIME_HH
  6. #define PEP_MIME_HH
  7. #include <pEp/message.h>
  8. #ifdef _WIN32
  9. #include <pEp/platform_windows.h>
  10. #endif
  11. namespace pEpMIME
  12. {
  13. // multipart messages are parsed recursively up to a maximum nesting level.
  14. // It should be large enough that all real-world mails can be parsed, but no
  15. // stack overflow occurs on maliciously crafted messages.
  16. // Deeper nested multipart messages are just put as attachment.
  17. // 100 seems to be a good default value, I think.
  18. const unsigned MaxMultipartNestingLevel = 100;
  19. // Parse the given string loosely as an "Internet Message" that aims to be RFC 5322
  20. // and MIME compliant (RFC 2046 etc.)
  21. //
  22. // parameters:
  23. // mime_text (in) : an "Internet Message"
  24. // length (in) : length of the mime_text, because it might contain NUL bytes
  25. //
  26. // return value:
  27. // a message struct that must be freed via free_message() or NULL on error.
  28. //
  29. message* parse_message(const char* mime_text, size_t length);
  30. // Generates an RFC 5322 compliant Internet Message from the given message struct.
  31. //
  32. // parameters:
  33. // msg (in) : the message that shall be serialized.
  34. // omit_fields(in) : only encode message body and attachments
  35. // transport_encode (in) : apply transport encoding (UTF-8 otherwise)
  36. //
  37. // return value:
  38. // a string holding an RFC-compliant "Internet Message", or NULL on error.
  39. // the string must be freed via pEp_free().
  40. //
  41. char* generate_message(const message* msg, bool omit_fields, bool transport_encode=true);
  42. } // end of namespace pEpMIME
  43. #endif // PEP_MIME_HH