src/mime.h
author Krista Bennett <krista@pep-project.org>
Tue, 22 Aug 2017 12:29:17 +0200
branchENGINE-233
changeset 1984 06e6c0f1d8fc
parent 1513 e7f7e42385b5
child 1987 313073d93cd9
permissions -rw-r--r--
ENGINE-233: Content-Disposition setting now possible in bloblist_t through mime.h
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
krista@1984
    12
typedef enum {
krista@1984
    13
    PEP_CONTENT_DISP_ATTACHMENT = 0,
krista@1984
    14
    PEP_CONTENT_DISP_INLINE = 1,
krista@1984
    15
    PEP_CONTENT_DISP_EXTENSION = 2,
krista@1984
    16
    PEP_CONTENT_DISP_NONE = -1      // must be affirmatively set
krista@1984
    17
} content_disposition_type;
krista@1984
    18
krista@1984
    19
DYNAMIC_API void set_blob_content_disposition(bloblist_t* blob, 
krista@1984
    20
                                              content_disposition_type disposition,
krista@1984
    21
                                              const char* extension_typename,
krista@1984
    22
                                              stringpair_list_t dispo_params);
krista@1984
    23
vb@48
    24
vb@117
    25
// is_PGP_message_text() - determine if text encodes a PGP message
vb@117
    26
//
vb@117
    27
//  parameters:
vb@117
    28
//      text (in)               text to examine
vb@117
    29
//
vb@117
    30
//  return value:
vb@117
    31
//      true if text is a PGP message, false otherwise
vb@117
    32
vb@117
    33
DYNAMIC_API bool is_PGP_message_text(const char *text);
vb@117
    34
vb@117
    35
vb@89
    36
// mime_encode_message() - encode a MIME message
vb@48
    37
//
vb@48
    38
//  parameters:
vb@89
    39
//      msg (in)                message to encode
vb@113
    40
//      omit_fields (in)        only encode message body and attachments
vb@87
    41
//      mimetext (out)          the resulting encoded text or NULL on any error
vb@48
    42
//
vb@48
    43
//  return value:
vb@48
    44
//      PEP_STATUS_OK           if everything worked
vb@48
    45
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
vb@48
    46
//      PEP_CANNOT_CREATE_TEMP_FILE
vb@48
    47
//                              if there are issues with temp files; in
vb@48
    48
//                              this case errno will contain the underlying
vb@48
    49
//                              error
vb@48
    50
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
vb@48
    51
//
vb@48
    52
//  caveat:
vb@89
    53
//      the resulttext will go to the ownership of the caller
vb@89
    54
//      the message will remain in the ownership of the caller
vb@113
    55
//      omit_fields is true for payload of PGP/MIME messages
vb@48
    56
vb@89
    57
DYNAMIC_API PEP_STATUS mime_encode_message(
vb@89
    58
        const message * msg,
vb@113
    59
        bool omit_fields,
vb@87
    60
        char **mimetext
vb@87
    61
    );
vb@87
    62
vb@87
    63
vb@89
    64
// mime_decode_message() - decode a MIME message
vb@87
    65
//
vb@87
    66
//  parameters:
vb@87
    67
//      mimetext (in)           MIME encoded text to decode
vb@269
    68
//      size (in)               size of text to decode
vb@89
    69
//      msg (out)               decoded message
vb@87
    70
//
vb@87
    71
//  return value:
vb@87
    72
//      PEP_STATUS_OK           if everything worked
vb@87
    73
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
vb@87
    74
//      PEP_CANNOT_CREATE_TEMP_FILE
vb@87
    75
//                              if there are issues with temp files; in
vb@87
    76
//                              this case errno will contain the underlying
vb@87
    77
//                              error
vb@87
    78
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
vb@87
    79
//
vb@87
    80
//  caveat:
vb@89
    81
//      the decoded message will go to the ownership of the caller; mimetext
vb@89
    82
//      will remain in the ownership of the caller
vb@87
    83
vb@89
    84
DYNAMIC_API PEP_STATUS mime_decode_message(
vb@87
    85
        const char *mimetext,
vb@269
    86
        size_t size,
vb@89
    87
        message **msg
vb@48
    88
    );
vb@48
    89
vb@48
    90
#ifdef __cplusplus
vb@48
    91
}
vb@48
    92
#endif