message-decoder.h revision 4e2d7dd2b201ae2083b6637d7ec0d37f49faca45
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen#ifndef MESSAGE_DECODER_H
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen#define MESSAGE_DECODER_H
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainenstruct message_header_line;
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainenenum message_cte {
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen MESSAGE_CTE_UNKNOWN = 0,
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen MESSAGE_CTE_78BIT,
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen MESSAGE_CTE_BINARY,
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen MESSAGE_CTE_QP,
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen MESSAGE_CTE_BASE64
e6055ac974358d31bb2269731dcac57fbe910cc2Timo Sirainen};
enum message_decoder_flags {
/* Return all headers and parts through
uni_utf8_to_decomposed_titlecase() */
MESSAGE_DECODER_FLAG_DTCASE = 0x01,
/* Return binary MIME parts as-is without any conversion. */
MESSAGE_DECODER_FLAG_RETURN_BINARY = 0x02
};
struct message_block;
/* Decode message's contents as UTF-8, both the headers and the MIME bodies.
The bodies are decoded from quoted-printable and base64 formats if needed. */
struct message_decoder_context *
message_decoder_init(enum message_decoder_flags flags);
void message_decoder_deinit(struct message_decoder_context **ctx);
/* Change the MESSAGE_DECODER_FLAG_RETURN_BINARY flag */
void message_decoder_set_return_binary(struct message_decoder_context *ctx,
bool set);
/* Decode input and return decoded output. Headers are returned only in their
full multiline forms.
Returns TRUE if output is given, FALSE if more data is needed. If the input
ends in a partial character, it's returned in the next output. */
bool message_decoder_decode_next_block(struct message_decoder_context *ctx,
struct message_block *input,
struct message_block *output);
/* Call whenever message changes */
void message_decoder_decode_reset(struct message_decoder_context *ctx);
/* Decode Content-Transfer-Encoding header. */
enum message_cte message_decoder_parse_cte(struct message_header_line *hdr);
#endif