message-parser.h revision 60576cd64e6a537413cd90104f7e862f71d48c81
#ifndef __MESSAGE_PARSER_H
#define __MESSAGE_PARSER_H
#include "message-size.h"
#define IS_LWSP(c) \
((c) == ' ' || (c) == '\t')
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_header_parser_ctx;
struct message_header_line {
const char *name;
const unsigned char *value;
const unsigned char *full_value;
const unsigned char *middle;
};
/* called once with hdr = NULL at the end of headers */
struct message_header_line *hdr,
void *context);
/* called once with size = 0 at the end of message part */
void *context);
/* callback is called for each field in message header. */
void *context);
struct message_size *hdr_size,
/* Initialize message parser. part_spool specifies where struct message_parts
are allocated from. */
struct message_parser_ctx *
/* 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);
/* skip_initial_lwsp controls if we should skip LWSP after "header: ".
Note that there may not be the single whitespace after "header:", and that
"header : " is also possible. These two conditions can't be determined from
struct message_header_line. */
struct message_header_parser_ctx *
int skip_initial_lwsp);
/* Read and return next header line. */
struct message_header_line *
#endif