src/mime.h
author Krista Bennett <krista@pep-project.org>
Wed, 07 Jun 2017 14:43:07 +0200
branchENGINE-9
changeset 1831 7f36a1b2ba63
parent 1513 e7f7e42385b5
child 1684 20643edc4c53
child 1984 06e6c0f1d8fc
permissions -rw-r--r--
ENGINE-9: Fixed copy-paste error leading to truncated content-ids. Seems to work :)
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@48
     4
#pragma once
vb@48
     5
vb@101
     6
#include "message.h"
vb@48
     7
vb@48
     8
#ifdef __cplusplus
vb@48
     9
extern "C" {
vb@48
    10
#endif
vb@48
    11
vb@48
    12
vb@117
    13
// is_PGP_message_text() - determine if text encodes a PGP message
vb@117
    14
//
vb@117
    15
//  parameters:
vb@117
    16
//      text (in)               text to examine
vb@117
    17
//
vb@117
    18
//  return value:
vb@117
    19
//      true if text is a PGP message, false otherwise
vb@117
    20
vb@117
    21
DYNAMIC_API bool is_PGP_message_text(const char *text);
vb@117
    22
vb@117
    23
vb@89
    24
// mime_encode_message() - encode a MIME message
vb@48
    25
//
vb@48
    26
//  parameters:
vb@89
    27
//      msg (in)                message to encode
vb@113
    28
//      omit_fields (in)        only encode message body and attachments
vb@87
    29
//      mimetext (out)          the resulting encoded text or NULL on any error
vb@48
    30
//
vb@48
    31
//  return value:
vb@48
    32
//      PEP_STATUS_OK           if everything worked
vb@48
    33
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
vb@48
    34
//      PEP_CANNOT_CREATE_TEMP_FILE
vb@48
    35
//                              if there are issues with temp files; in
vb@48
    36
//                              this case errno will contain the underlying
vb@48
    37
//                              error
vb@48
    38
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
vb@48
    39
//
vb@48
    40
//  caveat:
vb@89
    41
//      the resulttext will go to the ownership of the caller
vb@89
    42
//      the message will remain in the ownership of the caller
vb@113
    43
//      omit_fields is true for payload of PGP/MIME messages
vb@48
    44
vb@89
    45
DYNAMIC_API PEP_STATUS mime_encode_message(
vb@89
    46
        const message * msg,
vb@113
    47
        bool omit_fields,
vb@87
    48
        char **mimetext
vb@87
    49
    );
vb@87
    50
vb@87
    51
vb@89
    52
// mime_decode_message() - decode a MIME message
vb@87
    53
//
vb@87
    54
//  parameters:
vb@87
    55
//      mimetext (in)           MIME encoded text to decode
vb@269
    56
//      size (in)               size of text to decode
vb@89
    57
//      msg (out)               decoded message
vb@87
    58
//
vb@87
    59
//  return value:
vb@87
    60
//      PEP_STATUS_OK           if everything worked
vb@87
    61
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
vb@87
    62
//      PEP_CANNOT_CREATE_TEMP_FILE
vb@87
    63
//                              if there are issues with temp files; in
vb@87
    64
//                              this case errno will contain the underlying
vb@87
    65
//                              error
vb@87
    66
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
vb@87
    67
//
vb@87
    68
//  caveat:
vb@89
    69
//      the decoded message will go to the ownership of the caller; mimetext
vb@89
    70
//      will remain in the ownership of the caller
vb@87
    71
vb@89
    72
DYNAMIC_API PEP_STATUS mime_decode_message(
vb@87
    73
        const char *mimetext,
vb@269
    74
        size_t size,
vb@89
    75
        message **msg
vb@48
    76
    );
vb@48
    77
vb@48
    78
#ifdef __cplusplus
vb@48
    79
}
vb@48
    80
#endif
vb@48
    81