src/mime.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4592 f0e7ec9616c5
child 4785 08d521da5611
child 4792 7056435ab9e7
child 5246 67016f508d40
permissions -rw-r--r--
forgot test files
     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 
    28 //                                     attachments
    29 //      mimetext (out)                 the resulting encoded text or 
    30 //                                     NULL on any error
    31 //      has_pEp_msg_attachment (in)    is the first *attachment* to this 
    32 //                                     message an embedded pEp message
    33 //                                     which needs appropriate marking
    34 //                                     (forwarded=no, etc) and encoding?
    35 //                                     (this argument is internal to 
    36 //                                     pEp and should almost
    37 //                                     ALWAYS be false when used 
    38 //                                     by external callers, including
    39 //                                     adapters!!!)
    40 //                                  
    41 //
    42 //  return value:
    43 //      PEP_STATUS_OK           if everything worked
    44 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    45 //      PEP_CANNOT_CREATE_TEMP_FILE
    46 //                              if there are issues with temp files; in
    47 //                              this case errno will contain the underlying
    48 //                              error
    49 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    50 //
    51 //  caveat:
    52 //      the resulttext will go to the ownership of the caller
    53 //      the message will remain in the ownership of the caller
    54 //      omit_fields is true for payload of PGP/MIME messages
    55 //
    56 //      also: note that the encryption type will be used to determine what
    57 //      gets encoded from the message struct, so if using this on an 
    58 //      already-encrypted message, set the enc_format of the msg to PEP_enc_none.
    59 
    60 DYNAMIC_API PEP_STATUS mime_encode_message(
    61         const message * msg,
    62         bool omit_fields,
    63         char **mimetext,
    64         bool has_pEp_msg_attachment     
    65     );
    66 
    67 
    68 // mime_decode_message() - decode a MIME message
    69 //
    70 //  parameters:
    71 //      mimetext (in)           	   MIME encoded text to decode
    72 //      size (in)               	   size of text to decode
    73 //      msg (out)               	   decoded message
    74 //      has_possible_pEp_msg (inout)   If non-NULL, will return 
    75 //                                     true when the first attachment 
    76 //                                     is a potential pEp message
    77 //                                     (mime-type = message/rfc822 and 
    78 //                                     content-disposition parameter
    79 //                                     forwarded=no) 
    80 //      
    81 //
    82 //  return value:
    83 //      PEP_STATUS_OK           if everything worked
    84 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    85 //      PEP_CANNOT_CREATE_TEMP_FILE
    86 //                              if there are issues with temp files; in
    87 //                              this case errno will contain the underlying
    88 //                              error
    89 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    90 //
    91 //  caveat:
    92 //      the decoded message will go to the ownership of the caller; mimetext
    93 //      will remain in the ownership of the caller
    94 
    95 DYNAMIC_API PEP_STATUS mime_decode_message(
    96         const char *mimetext,
    97         size_t size,
    98         message **msg,
    99         bool* has_possible_pEp_msg
   100     );
   101 
   102 #ifdef __cplusplus
   103 }
   104 #endif