src/mime.h
author Volker Birk <vb@pep.foundation>
Thu, 01 Sep 2016 17:55:03 +0200
branchkeysync
changeset 1111 3c46dc58096d
parent 269 7eb06a6984fe
child 1513 e7f7e42385b5
permissions -rw-r--r--
merging
     1 #pragma once
     2 
     3 #include "message.h"
     4 
     5 #ifdef __cplusplus
     6 extern "C" {
     7 #endif
     8 
     9 
    10 // is_PGP_message_text() - determine if text encodes a PGP message
    11 //
    12 //  parameters:
    13 //      text (in)               text to examine
    14 //
    15 //  return value:
    16 //      true if text is a PGP message, false otherwise
    17 
    18 DYNAMIC_API bool is_PGP_message_text(const char *text);
    19 
    20 
    21 // mime_encode_message() - encode a MIME message
    22 //
    23 //  parameters:
    24 //      msg (in)                message to encode
    25 //      omit_fields (in)        only encode message body and attachments
    26 //      mimetext (out)          the resulting encoded text or NULL on any error
    27 //
    28 //  return value:
    29 //      PEP_STATUS_OK           if everything worked
    30 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    31 //      PEP_CANNOT_CREATE_TEMP_FILE
    32 //                              if there are issues with temp files; in
    33 //                              this case errno will contain the underlying
    34 //                              error
    35 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    36 //
    37 //  caveat:
    38 //      the resulttext will go to the ownership of the caller
    39 //      the message will remain in the ownership of the caller
    40 //      omit_fields is true for payload of PGP/MIME messages
    41 
    42 DYNAMIC_API PEP_STATUS mime_encode_message(
    43         const message * msg,
    44         bool omit_fields,
    45         char **mimetext
    46     );
    47 
    48 
    49 // mime_decode_message() - decode a MIME message
    50 //
    51 //  parameters:
    52 //      mimetext (in)           MIME encoded text to decode
    53 //      size (in)               size of text to decode
    54 //      msg (out)               decoded message
    55 //
    56 //  return value:
    57 //      PEP_STATUS_OK           if everything worked
    58 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    59 //      PEP_CANNOT_CREATE_TEMP_FILE
    60 //                              if there are issues with temp files; in
    61 //                              this case errno will contain the underlying
    62 //                              error
    63 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    64 //
    65 //  caveat:
    66 //      the decoded message will go to the ownership of the caller; mimetext
    67 //      will remain in the ownership of the caller
    68 
    69 DYNAMIC_API PEP_STATUS mime_decode_message(
    70         const char *mimetext,
    71         size_t size,
    72         message **msg
    73     );
    74 
    75 #ifdef __cplusplus
    76 }
    77 #endif
    78