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