1 #ifndef MESSAGE_PARSER_PRIVATE_H 2 #define MESSAGE_PARSER_PRIVATE_H 3 4 #include "message-parser.h" 5 6 /* RFC-2046 requires boundaries are max. 70 chars + "--" prefix + "--" suffix. 7 We'll add a bit more just in case. */ 8 #define BOUNDARY_STRING_MAX_LEN (70 + 10) 9 #define BOUNDARY_END_MAX_LEN (BOUNDARY_STRING_MAX_LEN + 2 + 2) 10 11 struct message_boundary { 12 struct message_boundary *next; 13 14 struct message_part *part; 15 char *boundary; 16 size_t len; 17 18 bool epilogue_found:1; 19 }; 20 21 struct message_parser_ctx { 22 pool_t part_pool; 23 struct istream *input; 24 struct message_part *parts, *part; 25 const char *broken_reason; 26 unsigned int nested_parts_count; 27 unsigned int total_parts_count; 28 29 enum message_header_parser_flags hdr_flags; 30 enum message_parser_flags flags; 31 unsigned int max_nested_mime_parts; 32 unsigned int max_total_mime_parts; 33 34 char *last_boundary; 35 struct message_boundary *boundaries; 36 37 struct message_part **next_part; 38 ARRAY(struct message_part **) next_part_stack; 39 40 size_t skip; 41 unsigned char last_chr; 42 unsigned int want_count; 43 44 struct message_header_parser_ctx *hdr_parser_ctx; 45 unsigned int prev_hdr_newline_size; 46 47 int (*parse_next_block)(struct message_parser_ctx *ctx, 48 struct message_block *block_r); 49 50 bool part_seen_content_type:1; 51 bool multipart:1; 52 bool preparsed:1; 53 bool eof:1; 54 }; 55 56 struct message_parser_ctx * 57 message_parser_init_int(struct istream *input, 58 const struct message_parser_settings *set); 59 int message_parser_read_more(struct message_parser_ctx *ctx, 60 struct message_block *block_r, bool *full_r); 61 62 #endif 63