message-parser.h revision 92c3a04218e0203426e3b6361359d00917ec3934
#ifndef __MESSAGE_PARSER_H
#define __MESSAGE_PARSER_H
#include "message-header-parser.h"
#include "message-size.h"
enum message_part_flags {
MESSAGE_PART_FLAG_MULTIPART = 0x01,
MESSAGE_PART_FLAG_MESSAGE_RFC822 = 0x04,
/* content-type: text/... */
MESSAGE_PART_FLAG_TEXT = 0x08,
/* content-transfer-encoding: binary */
MESSAGE_PART_FLAG_BINARY = 0x10,
/* message part header or body contains NULs */
MESSAGE_PART_FLAG_HAS_NULS = 0x20,
/* Mime-Version header exists. */
MESSAGE_PART_FLAG_IS_MIME = 0x40
};
struct message_part {
struct message_part *parent;
struct message_part *next;
struct message_part *children;
struct message_size header_size;
struct message_size body_size;
enum message_part_flags flags;
void *context;
};
struct message_parser_ctx;
struct message_block {
/* Message part this block belongs to */
struct message_part *part;
/* non-NULL if a header line was read */
struct message_header_line *hdr;
/* hdr = NULL, size = 0 block returned at the end of headers */
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 *
/* 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,
void *context);
message, hdr_callback is called for all headers. body_callback is called
for the body content. */
void *context);
/* callback is called for each field in message header. */
void *context);
#endif