6
struct imap_msgpart_open_result {
7
/* message contents with CRLF linefeeds */
11
/* if size was looked up using cache and it ends up being wrong,
12
this field can be used to log about cache corruption */
13
enum mail_fetch_field size_field;
14
/* TRUE if BINARY decoded content contains NUL characters */
15
bool binary_decoded_input_has_nuls;
18
struct imap_msgpart *imap_msgpart_full(void);
19
struct imap_msgpart *imap_msgpart_header(void);
20
struct imap_msgpart *imap_msgpart_body(void);
21
/* Parse section into imap_msgpart. Returns 0 and msgpart_r on success,
22
-1 if the section isn't valid. The same imap_msgpart can be used to open
24
int imap_msgpart_parse(const char *section, struct imap_msgpart **msgpart_r);
25
void imap_msgpart_free(struct imap_msgpart **msgpart);
27
/* Decode MIME parts with Content-Transfer-Encoding: base64/quoted-printable
28
to binary data (IMAP BINARY extension). If something can't be decoded, fails
29
with storage error set to MAIL_ERROR_CONVERSION. */
30
void imap_msgpart_set_decode_to_binary(struct imap_msgpart *msgpart);
32
/* Set the fetch to be partial. For unlimited size use (uoff_t)-1. */
33
void imap_msgpart_set_partial(struct imap_msgpart *msgpart,
34
uoff_t offset, uoff_t size);
35
uoff_t imap_msgpart_get_partial_offset(struct imap_msgpart *msgpart);
36
uoff_t imap_msgpart_get_partial_size(struct imap_msgpart *msgpart);
37
/* Return wanted_fields mask. */
38
enum mail_fetch_field imap_msgpart_get_fetch_data(struct imap_msgpart *msgpart);
40
/* Open message part refenced by IMAP section as istream. Returns 0 if
41
successful, -1 if storage error. Returned istream is initially referenced,
42
so i_stream_unref() must be called for it. */
43
int imap_msgpart_open(struct mail *mail, struct imap_msgpart *msgpart,
44
struct imap_msgpart_open_result *result_r);
45
/* Return msgpart's size without actually opening the stream (if possible). */
46
int imap_msgpart_size(struct mail *mail, struct imap_msgpart *msgpart,
49
/* Return msgpart's IMAP BODYPARTSTRUCTURE */
50
int imap_msgpart_bodypartstructure(struct mail *mail,
51
struct imap_msgpart *msgpart,
52
const char **bpstruct_r);
54
/* Header context is automatically created by imap_msgpart_open() and destroyed
55
by imap_msgpart_free(), but if you want to use the same imap_msgpart across
56
multiple mailboxes, you need to close the part before closing the mailbox. */
57
void imap_msgpart_close_mailbox(struct imap_msgpart *msgpart);