comparison src/lib-mail/message-parser.h @ 903:fd8888f6f037 HEAD

Naming style changes, finally got tired of most of the typedefs. Also the previous enum -> macro change reverted so that we don't use the highest bit anymore, that's incompatible with old indexes so they will be rebuilt.
author Timo Sirainen <tss@iki.fi>
date Sun, 05 Jan 2003 15:09:51 +0200
parents 0d5be52d7131
children 411006be3c66
comparison
equal deleted inserted replaced
902:5043e48c022f 903:fd8888f6f037
2 #define __MESSAGE_PARSER_H 2 #define __MESSAGE_PARSER_H
3 3
4 #define IS_LWSP(c) \ 4 #define IS_LWSP(c) \
5 ((c) == ' ' || (c) == '\t') 5 ((c) == ' ' || (c) == '\t')
6 6
7 typedef struct _MessagePart MessagePart; 7 enum message_part_flags {
8 typedef struct _MessagePosition MessagePosition;
9 typedef struct _MessageSize MessageSize;
10
11 typedef enum {
12 MESSAGE_PART_FLAG_MULTIPART = 0x01, 8 MESSAGE_PART_FLAG_MULTIPART = 0x01,
13 MESSAGE_PART_FLAG_MULTIPART_DIGEST = 0x02, 9 MESSAGE_PART_FLAG_MULTIPART_DIGEST = 0x02,
14 MESSAGE_PART_FLAG_MESSAGE_RFC822 = 0x04, 10 MESSAGE_PART_FLAG_MESSAGE_RFC822 = 0x04,
15 11
16 /* content-type: text/... */ 12 /* content-type: text/... */
17 MESSAGE_PART_FLAG_TEXT = 0x08, 13 MESSAGE_PART_FLAG_TEXT = 0x08,
18 14
19 /* content-transfer-encoding: binary */ 15 /* content-transfer-encoding: binary */
20 MESSAGE_PART_FLAG_BINARY = 0x10 16 MESSAGE_PART_FLAG_BINARY = 0x10
21 } MessagePartFlags; 17 };
22 18
23 struct _MessageSize { 19 struct message_size {
24 uoff_t physical_size; 20 uoff_t physical_size;
25 uoff_t virtual_size; 21 uoff_t virtual_size;
26 unsigned int lines; 22 unsigned int lines;
27 }; 23 };
28 24
29 struct _MessagePart { 25 struct message_part {
30 MessagePart *parent; 26 struct message_part *parent;
31 MessagePart *next; 27 struct message_part *next;
32 MessagePart *children; 28 struct message_part *children;
33 29
34 uoff_t physical_pos; /* absolute position from beginning of message */ 30 uoff_t physical_pos; /* absolute position from beginning of message */
35 MessageSize header_size; 31 struct message_size header_size;
36 MessageSize body_size; 32 struct message_size body_size;
37 33
38 MessagePartFlags flags; 34 enum message_part_flags flags;
39 void *context; 35 void *context;
40 }; 36 };
41 37
42 /* NOTE: name and value aren't \0-terminated. Also called once at end of 38 /* NOTE: name and value aren't \0-terminated. Also called once at end of
43 headers with name_len = value_len = 0. */ 39 headers with name_len = value_len = 0. */
44 typedef void (*MessageHeaderFunc)(MessagePart *part, 40 typedef void (*MessageHeaderFunc)(struct message_part *part,
45 const unsigned char *name, size_t name_len, 41 const unsigned char *name, size_t name_len,
46 const unsigned char *value, size_t value_len, 42 const unsigned char *value, size_t value_len,
47 void *context); 43 void *context);
48 44
49 /* func is called for each field in message header. */ 45 /* func is called for each field in message header. */
50 MessagePart *message_parse(Pool pool, IStream *input, 46 struct message_part *message_parse(pool_t pool, struct istream *input,
51 MessageHeaderFunc func, void *context); 47 MessageHeaderFunc func, void *context);
52 48
53 /* Call func for each field in message header. Fills the hdr_size. 49 /* Call func for each field in message header. Fills the hdr_size.
54 part can be NULL, just make sure your header function works with it. 50 part can be NULL, just make sure your header function works with it.
55 This function doesn't use data stack so your header function may save 51 This function doesn't use data stack so your header function may save
56 values to it. When finished, input will point to beginning of message 52 values to it. When finished, input will point to beginning of message
57 body. */ 53 body. */
58 void message_parse_header(MessagePart *part, IStream *input, 54 void message_parse_header(struct message_part *part, struct istream *input,
59 MessageSize *hdr_size, 55 struct message_size *hdr_size,
60 MessageHeaderFunc func, void *context); 56 MessageHeaderFunc func, void *context);
61 57
62 #endif 58 #endif