#ifndef MESSAGE_PARSER_H
#define MESSAGE_PARSER_H
#include "message-header-parser.h"
#include "message-part.h"
enum message_parser_flags {
/* Don't return message bodies in message_blocks. */
/* Buggy software creates Content-Type: headers without Mime-Version:
header. By default we allow this and assume message is MIME if
Content-Type: is found. This flag disables this. */
/* Return multipart (preamble and epilogue) blocks */
/* Return --boundary lines */
};
struct message_parser_ctx;
struct message_block {
/* Message part this block belongs to */
/* non-NULL if a header line was read */
/* hdr = NULL, size = 0 block returned at the end of headers for the
empty line between header and body (unless the header is truncated).
Later on data and size>0 is returned for blocks of mail body that
is read (see message_parser_flags for what is actually returned) */
const unsigned char *data;
};
/* called once with hdr = NULL at the end of headers */
struct message_header_line *hdr,
void *context);
/* Initialize message parser. part_spool specifies where struct message_parts
are allocated from. */
struct message_parser_ctx *
enum message_parser_flags flags);
/* Deinitialize message parser. The ctx must NOT have been created by
message_parser_init_from_parts(). */
struct message_part **parts_r);
/* Use preparsed parts to speed up parsing. */
struct message_parser_ctx *
enum message_parser_flags flags);
/* Same as message_parser_deinit(), but return an error message describing
why the preparsed parts didn't match the message. This can also safely be
called even when preparsed parts weren't used - it'll always just return
success in that case. */
struct message_part **parts_r,
const char **error_r);
/* Read the next block of a message. Returns 1 if block is returned, 0 if
input stream is non-blocking and more data needs to be read, -1 when all is
done or error occurred (see stream's error status). */
struct message_block *block_r);
/* Read and parse header. */
struct message_size *hdr_size,
CALLBACK_TYPECHECK(callback, void (*)( \
struct message_part *, \
message, hdr_callback is called for all headers. body_callback is called
for the body content. */
void (*)(struct message_part *, \
#endif