src/mime.h
author Krista Bennett <krista@pep-project.org>
Wed, 25 Oct 2017 10:29:16 +0200
branchENGINE-298
changeset 2200 644d22d740f0
parent 2155 9d16b7e422cc
child 3710 d7c1395f473c
permissions -rw-r--r--
ENGINE-298: transport encoding should only take place when the message is at the last stage before outbound return. Added a transport_encode flag to several of the MIME-tree building functions, as libetpan does not distinguish between building the MIME tree and encoding its parts.
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include "message.h"
     7 
     8 #ifdef __cplusplus
     9 extern "C" {
    10 #endif
    11 
    12 // is_PGP_message_text() - determine if text encodes a PGP message
    13 //
    14 //  parameters:
    15 //      text (in)               text to examine
    16 //
    17 //  return value:
    18 //      true if text is a PGP message, false otherwise
    19 
    20 DYNAMIC_API bool is_PGP_message_text(const char *text);
    21 
    22 
    23 // mime_encode_message() - encode a MIME message
    24 //
    25 //  parameters:
    26 //      msg (in)                message to encode
    27 //      omit_fields (in)        only encode message body and attachments
    28 //      mimetext (out)          the resulting encoded text or NULL on any error
    29 //
    30 //  return value:
    31 //      PEP_STATUS_OK           if everything worked
    32 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    33 //      PEP_CANNOT_CREATE_TEMP_FILE
    34 //                              if there are issues with temp files; in
    35 //                              this case errno will contain the underlying
    36 //                              error
    37 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    38 //
    39 //  caveat:
    40 //      the resulttext will go to the ownership of the caller
    41 //      the message will remain in the ownership of the caller
    42 //      omit_fields is true for payload of PGP/MIME messages
    43 //
    44 //      also: note that the encryption type will be used to determine what
    45 //      gets encoded from the message struct, so if using this on an 
    46 //      already-encrypted message, set the enc_format of the msg to PEP_enc_none.
    47 
    48 DYNAMIC_API PEP_STATUS mime_encode_message(
    49         const message * msg,
    50         bool omit_fields,
    51         char **mimetext
    52     );
    53 
    54 
    55 // mime_decode_message() - decode a MIME message
    56 //
    57 //  parameters:
    58 //      mimetext (in)           MIME encoded text to decode
    59 //      size (in)               size of text to decode
    60 //      msg (out)               decoded message
    61 //
    62 //  return value:
    63 //      PEP_STATUS_OK           if everything worked
    64 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    65 //      PEP_CANNOT_CREATE_TEMP_FILE
    66 //                              if there are issues with temp files; in
    67 //                              this case errno will contain the underlying
    68 //                              error
    69 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    70 //
    71 //  caveat:
    72 //      the decoded message will go to the ownership of the caller; mimetext
    73 //      will remain in the ownership of the caller
    74 
    75 DYNAMIC_API PEP_STATUS mime_decode_message(
    76         const char *mimetext,
    77         size_t size,
    78         message **msg
    79     );
    80 
    81 /* sometimes we don't want to transport encode */
    82 PEP_STATUS _mime_encode_message_internal(
    83         const message * msg,
    84         bool omit_fields,
    85         char **mimetext,
    86         bool transport_encode
    87     );
    88 
    89 
    90 #ifdef __cplusplus
    91 }
    92 #endif