src/mime.h
author Krista Bennett <krista@pep-project.org>
Tue, 22 Aug 2017 14:41:11 +0200
branchENGINE-233
changeset 1987 313073d93cd9
parent 1984 06e6c0f1d8fc
child 2155 9d16b7e422cc
permissions -rw-r--r--
ENGINE-233: passes tests
     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 DYNAMIC_API PEP_STATUS mime_encode_message(
    45         const message * msg,
    46         bool omit_fields,
    47         char **mimetext
    48     );
    49 
    50 
    51 // mime_decode_message() - decode a MIME message
    52 //
    53 //  parameters:
    54 //      mimetext (in)           MIME encoded text to decode
    55 //      size (in)               size of text to decode
    56 //      msg (out)               decoded message
    57 //
    58 //  return value:
    59 //      PEP_STATUS_OK           if everything worked
    60 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    61 //      PEP_CANNOT_CREATE_TEMP_FILE
    62 //                              if there are issues with temp files; in
    63 //                              this case errno will contain the underlying
    64 //                              error
    65 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    66 //
    67 //  caveat:
    68 //      the decoded message will go to the ownership of the caller; mimetext
    69 //      will remain in the ownership of the caller
    70 
    71 DYNAMIC_API PEP_STATUS mime_decode_message(
    72         const char *mimetext,
    73         size_t size,
    74         message **msg
    75     );
    76 
    77 #ifdef __cplusplus
    78 }
    79 #endif