Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-imap/imap-bodystructure.c @ 9595:166a188f9165 HEAD
mbox: Fields weren't being added to cache file during message saving.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 30 Jul 2010 16:55:58 +0100 |
parents | 00cd9aacd03c |
children |
rev | line source |
---|---|
9532
00cd9aacd03c
Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
1 /* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */ |
0 | 2 |
3 #include "lib.h" | |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
4 #include "buffer.h" |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
647
diff
changeset
|
5 #include "istream.h" |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
6 #include "str.h" |
0 | 7 #include "message-parser.h" |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
8 #include "rfc822-parser.h" |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
9 #include "rfc2231-parser.h" |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
10 #include "imap-parser.h" |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
11 #include "imap-quote.h" |
0 | 12 #include "imap-envelope.h" |
13 #include "imap-bodystructure.h" | |
14 | |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
15 #define DEFAULT_CHARSET \ |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
16 "\"charset\" \"us-ascii\"" |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
17 |
0 | 18 #define EMPTY_BODYSTRUCTURE \ |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
19 "(\"text\" \"plain\" ("DEFAULT_CHARSET") NIL NIL \"7bit\" 0 0)" |
0 | 20 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
21 struct message_part_body_data { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
22 pool_t pool; |
4816
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
23 const char *content_type, *content_subtype; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
24 const char *content_type_params; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
25 const char *content_transfer_encoding; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
26 const char *content_id; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
27 const char *content_description; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
28 const char *content_disposition; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
29 const char *content_disposition_params; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
30 const char *content_md5; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
31 const char *content_language; |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
32 const char *content_location; |
0 | 33 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
34 struct message_part_envelope_data *envelope; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
35 }; |
0 | 36 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
37 static void parse_content_type(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
38 struct message_header_line *hdr) |
0 | 39 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
40 struct rfc822_parser_context parser; |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
41 const char *value, *const *results; |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
42 string_t *str; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
43 unsigned int i; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
44 bool charset_found = FALSE; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
45 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
46 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
47 (void)rfc822_skip_lwsp(&parser); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
48 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
49 str = t_str_new(256); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
50 if (rfc822_parse_content_type(&parser, str) < 0) |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
51 return; |
0 | 52 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
53 /* Save content type and subtype */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
54 value = str_c(str); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
55 for (i = 0; value[i] != '\0'; i++) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
56 if (value[i] == '/') { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
57 data->content_subtype = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
58 imap_quote(data->pool, str_data(str) + i + 1, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
59 str_len(str) - (i + 1)); |
0 | 60 break; |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
61 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
62 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
63 data->content_type = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
64 imap_quote(data->pool, str_data(str), i); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
65 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
66 /* parse parameters and save them */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
67 str_truncate(str, 0); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
68 (void)rfc2231_parse(&parser, &results); |
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
69 for (; *results != NULL; results += 2) { |
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
70 if (strcasecmp(results[0], "charset") == 0) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
71 charset_found = TRUE; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
72 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
73 str_append_c(str, ' '); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
74 imap_quote_append_string(str, results[0], TRUE); |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
75 str_append_c(str, ' '); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
76 imap_quote_append_string(str, results[1], TRUE); |
0 | 77 } |
78 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
79 if (!charset_found && |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
80 strcasecmp(data->content_type, "\"text\"") == 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
81 /* set a default charset */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
82 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
83 str_append(str, DEFAULT_CHARSET); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
84 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
85 if (str_len(str) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
86 data->content_type_params = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
87 p_strdup(data->pool, str_c(str) + 1); |
896
21ffcce83c70
Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
88 } |
0 | 89 } |
90 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
91 static void parse_content_transfer_encoding(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
92 struct message_header_line *hdr) |
0 | 93 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
94 struct rfc822_parser_context parser; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
95 string_t *str; |
0 | 96 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
97 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
98 (void)rfc822_skip_lwsp(&parser); |
0 | 99 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
100 str = t_str_new(256); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
101 if (rfc822_parse_mime_token(&parser, str) >= 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
102 data->content_transfer_encoding = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
103 imap_quote(data->pool, str_data(str), str_len(str)); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
104 } |
0 | 105 } |
106 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
107 static void parse_content_disposition(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
108 struct message_header_line *hdr) |
0 | 109 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
110 struct rfc822_parser_context parser; |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
111 const char *const *results; |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
112 string_t *str; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
113 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
114 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
115 (void)rfc822_skip_lwsp(&parser); |
0 | 116 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
117 str = t_str_new(256); |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
118 if (rfc822_parse_mime_token(&parser, str) < 0) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
119 return; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
120 data->content_disposition = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
121 imap_quote(data->pool, str_data(str), str_len(str)); |
0 | 122 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
123 /* parse parameters and save them */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
124 str_truncate(str, 0); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
125 (void)rfc2231_parse(&parser, &results); |
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
126 for (; *results != NULL; results += 2) { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
127 str_append_c(str, ' '); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
128 imap_quote_append_string(str, results[0], TRUE); |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
129 str_append_c(str, ' '); |
7950
3412c43d6707
Merge RFC 2231 header continuations in BODY/BODYSTRUCTURE replies. Also use
Timo Sirainen <tss@iki.fi>
parents:
7949
diff
changeset
|
130 imap_quote_append_string(str, results[1], TRUE); |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
131 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
132 if (str_len(str) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
133 data->content_disposition_params = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
134 p_strdup(data->pool, str_c(str) + 1); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
135 } |
0 | 136 } |
137 | |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
138 static void parse_content_language(const unsigned char *value, size_t value_len, |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
139 struct message_part_body_data *data) |
0 | 140 { |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
141 struct rfc822_parser_context parser; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
142 string_t *str; |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
143 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
144 /* Language-Header = "Content-Language" ":" 1#Language-tag |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
145 Language-Tag = Primary-tag *( "-" Subtag ) |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
146 Primary-tag = 1*8ALPHA |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
147 Subtag = 1*8ALPHA */ |
0 | 148 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
149 rfc822_parser_init(&parser, value, value_len, NULL); |
0 | 150 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
151 str = t_str_new(128); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
152 str_append_c(str, '"'); |
0 | 153 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
154 (void)rfc822_skip_lwsp(&parser); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
155 while (rfc822_parse_atom(&parser, str) >= 0) { |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
156 str_append(str, "\" \""); |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
157 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
158 if (parser.data == parser.end || *parser.data != ',') |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
159 break; |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
160 parser.data++; |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
161 (void)rfc822_skip_lwsp(&parser); |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
162 } |
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
163 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
164 if (str_len(str) > 1) { |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
165 str_truncate(str, str_len(str) - 2); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
166 data->content_language = p_strdup(data->pool, str_c(str)); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
167 } |
0 | 168 } |
169 | |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
170 static void parse_content_header(struct message_part_body_data *d, |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
171 struct message_header_line *hdr, |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
172 pool_t pool) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
173 { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
174 const char *name = hdr->name + strlen("Content-"); |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
175 const unsigned char *value; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
176 size_t value_len; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
177 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
178 if (hdr->continues) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
179 hdr->use_full_value = TRUE; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
180 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
181 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
182 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
183 value = hdr->full_value; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
184 value_len = hdr->full_value_len; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
185 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
186 switch (*name) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
187 case 'i': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
188 case 'I': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
189 if (strcasecmp(name, "ID") == 0 && d->content_id == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
190 d->content_id = imap_quote(pool, value, value_len); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
191 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
192 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
193 case 'm': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
194 case 'M': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
195 if (strcasecmp(name, "MD5") == 0 && d->content_md5 == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
196 d->content_md5 = imap_quote(pool, value, value_len); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
197 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
198 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
199 case 't': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
200 case 'T': |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
201 if (strcasecmp(name, "Type") == 0 && d->content_type == NULL) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
202 parse_content_type(d, hdr); |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
203 else if (strcasecmp(name, "Transfer-Encoding") == 0 && |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
204 d->content_transfer_encoding == NULL) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
205 parse_content_transfer_encoding(d, hdr); |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
206 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
207 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
208 case 'l': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
209 case 'L': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
210 if (strcasecmp(name, "Language") == 0 && |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
211 d->content_language == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
212 parse_content_language(value, value_len, d); |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
213 else if (strcasecmp(name, "Location") == 0 && |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
214 d->content_location == NULL) { |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
215 d->content_location = |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
216 imap_quote(pool, value, value_len); |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
217 } |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
218 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
219 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
220 case 'd': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
221 case 'D': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
222 if (strcasecmp(name, "Description") == 0 && |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
223 d->content_description == NULL) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
224 d->content_description = |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
225 imap_quote(pool, value, value_len); |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
226 } else if (strcasecmp(name, "Disposition") == 0 && |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
227 d->content_disposition_params == NULL) { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
228 parse_content_disposition(d, hdr); |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
229 } |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
230 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
231 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
232 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
233 |
1689
c07b98265577
If BODY/BODYSTRUCTURE is requested with some other headers, parse the
Timo Sirainen <tss@iki.fi>
parents:
1665
diff
changeset
|
234 void imap_bodystructure_parse_header(pool_t pool, struct message_part *part, |
c07b98265577
If BODY/BODYSTRUCTURE is requested with some other headers, parse the
Timo Sirainen <tss@iki.fi>
parents:
1665
diff
changeset
|
235 struct message_header_line *hdr) |
0 | 236 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
237 struct message_part_body_data *part_data; |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
238 struct message_part_envelope_data *envelope; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
239 bool parent_rfc822; |
0 | 240 |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
241 if (hdr == NULL) { |
7014
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
242 if (part->context == NULL) { |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
243 /* no Content-* headers. add an empty context |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
244 structure anyway. */ |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
245 part->context = part_data = |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
246 p_new(pool, struct message_part_body_data, 1); |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
247 part_data->pool = pool; |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
248 } else if ((part->flags & MESSAGE_PART_FLAG_IS_MIME) == 0) { |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
249 /* If there was no Mime-Version, forget all |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
250 the Content-stuff */ |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
251 part_data = part->context; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
252 envelope = part_data->envelope; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
253 |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
254 memset(part_data, 0, sizeof(*part_data)); |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
255 part_data->pool = pool; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
256 part_data->envelope = envelope; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
257 } |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
258 return; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
259 } |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
260 |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
261 if (hdr->eoh) |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
262 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
263 |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
264 parent_rfc822 = part->parent != NULL && |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
265 (part->parent->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0; |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
266 if (!parent_rfc822 && strncasecmp(hdr->name, "Content-", 8) != 0) |
0 | 267 return; |
268 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
269 if (part->context == NULL) { |
0 | 270 /* initialize message part data */ |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
271 part->context = part_data = |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
272 p_new(pool, struct message_part_body_data, 1); |
0 | 273 part_data->pool = pool; |
274 } | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
275 part_data = part->context; |
0 | 276 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
277 if (strncasecmp(hdr->name, "Content-", 8) == 0) { |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
278 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
279 parse_content_header(part_data, hdr, pool); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
280 } T_END; |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
281 } |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
282 |
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
283 if (parent_rfc822) { |
0 | 284 /* message/rfc822, we need the envelope */ |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
285 imap_envelope_parse_header(pool, &part_data->envelope, hdr); |
0 | 286 } |
287 } | |
288 | |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
289 static void part_write_body_multipart(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
290 string_t *str, bool extended) |
0 | 291 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
292 struct message_part_body_data *data = part->context; |
0 | 293 |
294 if (part->children != NULL) | |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
295 imap_bodystructure_write(part->children, str, extended); |
0 | 296 else { |
297 /* no parts in multipart message, | |
298 that's not allowed. write a single | |
299 0-length text/plain structure */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
300 str_append(str, EMPTY_BODYSTRUCTURE); |
0 | 301 } |
302 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
303 str_append_c(str, ' '); |
647
1acbf6c8758c
handle broken multipart messages without crashing
Timo Sirainen <tss@iki.fi>
parents:
593
diff
changeset
|
304 if (data->content_subtype != NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
305 str_append(str, data->content_subtype); |
647
1acbf6c8758c
handle broken multipart messages without crashing
Timo Sirainen <tss@iki.fi>
parents:
593
diff
changeset
|
306 else |
896
21ffcce83c70
Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
307 str_append(str, "\"x-unknown\""); |
0 | 308 |
309 if (!extended) | |
310 return; | |
311 | |
312 /* BODYSTRUCTURE data */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
313 str_append_c(str, ' '); |
0 | 314 if (data->content_type_params == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
315 str_append(str, "NIL"); |
0 | 316 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
317 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
318 str_append(str, data->content_type_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
319 str_append_c(str, ')'); |
0 | 320 } |
321 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
322 str_append_c(str, ' '); |
0 | 323 if (data->content_disposition == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
324 str_append(str, "NIL"); |
0 | 325 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
326 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
327 str_append(str, data->content_disposition); |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
328 str_append_c(str, ' '); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
329 |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
330 if (data->content_disposition_params == NULL) |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
331 str_append(str, "NIL"); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
332 else { |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
333 str_append_c(str, '('); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
334 str_append(str, data->content_disposition_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
335 str_append_c(str, ')'); |
0 | 336 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
337 str_append_c(str, ')'); |
0 | 338 } |
339 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
340 str_append_c(str, ' '); |
0 | 341 if (data->content_language == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
342 str_append(str, "NIL"); |
0 | 343 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
344 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
345 str_append(str, data->content_language); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
346 str_append_c(str, ')'); |
0 | 347 } |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
348 |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
349 str_append_c(str, ' '); |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
350 if (data->content_location == NULL) |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
351 str_append(str, "NIL"); |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
352 else |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
353 str_append(str, data->content_location); |
0 | 354 } |
355 | |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
356 static void part_write_body(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
357 string_t *str, bool extended) |
0 | 358 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
359 struct message_part_body_data *data = part->context; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
360 bool text; |
0 | 361 |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
362 if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) { |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
363 str_append(str, "\"message\" \"rfc822\""); |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
364 text = FALSE; |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
365 } else { |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
366 /* "content type" "subtype" */ |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
367 text = data->content_type == NULL || |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
368 strcasecmp(data->content_type, "\"text\"") == 0; |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
369 str_append(str, NVL(data->content_type, "\"text\"")); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
370 str_append_c(str, ' '); |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
371 |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
372 if (data->content_subtype != NULL) |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
373 str_append(str, data->content_subtype); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
374 else { |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
375 if (text) |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
376 str_append(str, "\"plain\""); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
377 else |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
378 str_append(str, "\"unknown\""); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
379 |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
380 } |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
381 } |
0 | 382 |
383 /* ("content type param key" "value" ...) */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
384 str_append_c(str, ' '); |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
385 if (data->content_type_params == NULL) { |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
386 if (!text) |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
387 str_append(str, "NIL"); |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
388 else |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
389 str_append(str, "("DEFAULT_CHARSET")"); |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
390 } else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
391 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
392 str_append(str, data->content_type_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
393 str_append_c(str, ')'); |
0 | 394 } |
395 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
396 str_printfa(str, " %s %s %s %"PRIuUOFF_T, |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
397 NVL(data->content_id, "NIL"), |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
398 NVL(data->content_description, "NIL"), |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
399 NVL(data->content_transfer_encoding, "\"7bit\""), |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
400 part->body_size.virtual_size); |
0 | 401 |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
402 if (text) { |
0 | 403 /* text/.. contains line count */ |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
404 str_printfa(str, " %u", part->body_size.lines); |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
405 } else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) { |
0 | 406 /* message/rfc822 contains envelope + body + line count */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
407 struct message_part_body_data *child_data; |
1663
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
408 struct message_part_envelope_data *env_data; |
0 | 409 |
410 i_assert(part->children != NULL); | |
411 i_assert(part->children->next == NULL); | |
412 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
413 child_data = part->children->context; |
7014
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
414 env_data = child_data->envelope; |
0 | 415 |
1664 | 416 str_append(str, " ("); |
1663
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
417 imap_envelope_write_part_data(env_data, str); |
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
418 str_append(str, ") "); |
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
419 |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
420 imap_bodystructure_write(part->children, str, extended); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
421 str_printfa(str, " %u", part->body_size.lines); |
0 | 422 } |
423 | |
424 if (!extended) | |
425 return; | |
426 | |
427 /* BODYSTRUCTURE data */ | |
428 | |
429 /* "md5" ("content disposition" ("disposition" "params")) | |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
430 ("body" "language" "params") "location" */ |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
431 str_append_c(str, ' '); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
432 str_append(str, NVL(data->content_md5, "NIL")); |
0 | 433 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
434 str_append_c(str, ' '); |
0 | 435 if (data->content_disposition == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
436 str_append(str, "NIL"); |
0 | 437 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
438 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
439 str_append(str, data->content_disposition); |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
440 str_append_c(str, ' '); |
0 | 441 |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
442 if (data->content_disposition_params == NULL) |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
443 str_append(str, "NIL"); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
444 else { |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
445 str_append_c(str, '('); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
446 str_append(str, data->content_disposition_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
447 str_append_c(str, ')'); |
0 | 448 } |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
449 |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
450 str_append_c(str, ')'); |
0 | 451 } |
452 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
453 str_append_c(str, ' '); |
0 | 454 if (data->content_language == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
455 str_append(str, "NIL"); |
0 | 456 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
457 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
458 str_append(str, data->content_language); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
459 str_append_c(str, ')'); |
0 | 460 } |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
461 |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
462 str_append_c(str, ' '); |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
463 if (data->content_location == NULL) |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
464 str_append(str, "NIL"); |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
465 else |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
466 str_append(str, data->content_location); |
0 | 467 } |
468 | |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
469 bool imap_bodystructure_is_plain_7bit(const struct message_part *part) |
3460
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
470 { |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
471 const struct message_part_body_data *data = part->context; |
3460
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
472 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
473 i_assert(part->parent == NULL); |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
474 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
475 /* if content-type is text/xxx we don't have to check any |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
476 multipart stuff */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
477 if ((part->flags & MESSAGE_PART_FLAG_TEXT) == 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
478 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
479 if (part->next != NULL || part->children != NULL) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
480 return FALSE; /* shouldn't happen normally.. */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
481 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
482 /* must be text/plain */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
483 if (data->content_subtype != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
484 strcasecmp(data->content_subtype, "\"plain\"") != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
485 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
486 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
487 /* only allowed parameter is charset=us-ascii, which is also default */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
488 if (data->content_type_params != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
489 strcasecmp(data->content_type_params, DEFAULT_CHARSET) != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
490 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
491 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
492 if (data->content_id != NULL || |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
493 data->content_description != NULL) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
494 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
495 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
496 if (data->content_transfer_encoding != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
497 strcasecmp(data->content_transfer_encoding, "\"7bit\"") != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
498 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
499 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
500 /* BODYSTRUCTURE checks: */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
501 if (data->content_md5 != NULL || |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
502 data->content_disposition != NULL || |
7949
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
503 data->content_language != NULL || |
e787f6cae97c
Added missing Content-Language: support for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
504 data->content_location != NULL) |
3460
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
505 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
506 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
507 return TRUE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
508 } |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
509 |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
510 void imap_bodystructure_write(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
511 string_t *dest, bool extended) |
0 | 512 { |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
513 i_assert(part->parent != NULL || part->next == NULL); |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
514 |
0 | 515 while (part != NULL) { |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
516 if (part->parent != NULL) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
517 str_append_c(dest, '('); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
518 |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
519 if (part->flags & MESSAGE_PART_FLAG_MULTIPART) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
520 part_write_body_multipart(part, dest, extended); |
0 | 521 else |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
522 part_write_body(part, dest, extended); |
0 | 523 |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
524 if (part->parent != NULL) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
525 str_append_c(dest, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
526 |
0 | 527 part = part->next; |
528 } | |
529 } | |
530 | |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
531 static bool str_append_imap_arg(string_t *str, const struct imap_arg *arg) |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
532 { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
533 switch (arg->type) { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
534 case IMAP_ARG_NIL: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
535 str_append(str, "NIL"); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
536 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
537 case IMAP_ARG_ATOM: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
538 str_append(str, IMAP_ARG_STR(arg)); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
539 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
540 case IMAP_ARG_STRING: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
541 str_append_c(str, '"'); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
542 str_append(str, IMAP_ARG_STR(arg)); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
543 str_append_c(str, '"'); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
544 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
545 case IMAP_ARG_LITERAL: { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
546 const char *argstr = IMAP_ARG_STR(arg); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
547 |
4280
92bf418b8a60
BODYSTRUCTURE -> BODY translation was missing CRLF after literal.
Timo Sirainen <tss@iki.fi>
parents:
4070
diff
changeset
|
548 str_printfa(str, "{%"PRIuSIZE_T"}\r\n", strlen(argstr)); |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
549 str_append(str, argstr); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
550 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
551 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
552 default: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
553 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
554 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
555 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
556 return TRUE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
557 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
558 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
559 static bool imap_write_list(const struct imap_arg *args, string_t *str) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
560 { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
561 /* don't do any typechecking, just write it out */ |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
562 str_append_c(str, '('); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
563 while (args->type != IMAP_ARG_EOL) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
564 if (!str_append_imap_arg(str, args)) { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
565 if (args->type != IMAP_ARG_LIST) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
566 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
567 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
568 if (!imap_write_list(IMAP_ARG_LIST_ARGS(args), str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
569 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
570 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
571 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
572 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
573 if (args->type != IMAP_ARG_EOL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
574 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
575 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
576 str_append_c(str, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
577 return TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
578 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
579 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
580 static bool imap_parse_bodystructure_args(const struct imap_arg *args, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
581 string_t *str) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
582 { |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5334
diff
changeset
|
583 const struct imap_arg *subargs; |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
584 const struct imap_arg *list_args; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
585 bool multipart, text, message_rfc822; |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
586 int i; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
587 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
588 multipart = FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
589 while (args->type == IMAP_ARG_LIST) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
590 str_append_c(str, '('); |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
591 list_args = IMAP_ARG_LIST_ARGS(args); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
592 if (!imap_parse_bodystructure_args(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
593 return FALSE; |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
594 str_append_c(str, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
595 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
596 multipart = TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
597 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
598 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
599 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
600 if (multipart) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
601 /* next is subtype of Content-Type. rest is skipped. */ |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
602 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
603 return str_append_imap_arg(str, args); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
604 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
605 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
606 /* "content type" "subtype" */ |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
607 if (args[0].type == IMAP_ARG_NIL || args[1].type == IMAP_ARG_NIL) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
608 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
609 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
610 if (!str_append_imap_arg(str, &args[0])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
611 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
612 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
613 if (!str_append_imap_arg(str, &args[1])) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
614 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
615 |
3571 | 616 text = strcasecmp(IMAP_ARG_STR_NONULL(&args[0]), "text") == 0; |
617 message_rfc822 = | |
618 strcasecmp(IMAP_ARG_STR_NONULL(&args[0]), "message") == 0 && | |
619 strcasecmp(IMAP_ARG_STR_NONULL(&args[1]), "rfc822") == 0; | |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
620 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
621 args += 2; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
622 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
623 /* ("content type param key" "value" ...) | NIL */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
624 if (args->type == IMAP_ARG_LIST) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
625 str_append(str, " ("); |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
626 subargs = IMAP_ARG_LIST_ARGS(args); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
627 for (; subargs->type != IMAP_ARG_EOL; ) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
628 if (!str_append_imap_arg(str, &subargs[0])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
629 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
630 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
631 if (!str_append_imap_arg(str, &subargs[1])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
632 return FALSE; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
633 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
634 subargs += 2; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
635 if (subargs->type == IMAP_ARG_EOL) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
636 break; |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
637 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
638 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
639 str_append(str, ")"); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
640 } else if (args->type == IMAP_ARG_NIL) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
641 str_append(str, " NIL"); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
642 } else { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
643 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
644 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
645 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
646 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
647 /* "content id" "content description" "transfer encoding" size */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
648 for (i = 0; i < 4; i++, args++) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
649 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
650 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
651 if (!str_append_imap_arg(str, args)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
652 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
653 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
654 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
655 if (text) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
656 /* text/xxx - text lines */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
657 if (args->type != IMAP_ARG_ATOM) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
658 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
659 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
660 str_append_c(str, ' '); |
877
7935347f54f1
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
Timo Sirainen <tss@iki.fi>
parents:
862
diff
changeset
|
661 str_append(str, IMAP_ARG_STR(args)); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
662 } else if (message_rfc822) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
663 /* message/rfc822 - envelope + bodystructure + text lines */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
664 if (args[0].type != IMAP_ARG_LIST || |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
665 args[1].type != IMAP_ARG_LIST || |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
666 args[2].type != IMAP_ARG_ATOM) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
667 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
668 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
669 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
670 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
671 list_args = IMAP_ARG_LIST_ARGS(&args[0]); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
672 if (!imap_write_list(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
673 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
674 |
4027
0e7a9b0aa8c3
BODYSTRUCTURE -> BODY conversion was broken with mails containing
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
675 str_append(str, " ("); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
676 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
677 list_args = IMAP_ARG_LIST_ARGS(&args[1]); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
678 if (!imap_parse_bodystructure_args(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
679 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
680 |
4027
0e7a9b0aa8c3
BODYSTRUCTURE -> BODY conversion was broken with mails containing
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
681 str_append(str, ") "); |
877
7935347f54f1
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
Timo Sirainen <tss@iki.fi>
parents:
862
diff
changeset
|
682 str_append(str, IMAP_ARG_STR(&args[2])); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
683 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
684 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
685 return TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
686 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
687 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
688 bool imap_body_parse_from_bodystructure(const char *bodystructure, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
689 string_t *dest) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
690 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
691 struct istream *input; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
692 struct imap_parser *parser; |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5334
diff
changeset
|
693 const struct imap_arg *args; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
694 int ret; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
695 |
6142
6c0bfc35af03
Removed memory pool parameter from iostreams. Default pool was almost always
Timo Sirainen <tss@iki.fi>
parents:
6117
diff
changeset
|
696 input = i_stream_create_from_data(bodystructure, strlen(bodystructure)); |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
647
diff
changeset
|
697 (void)i_stream_read(input); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
698 |
1591
6eca99b727a0
IMAP parser memory limits are now enforced by bytes per line rather than
Timo Sirainen <tss@iki.fi>
parents:
1568
diff
changeset
|
699 parser = imap_parser_create(input, NULL, (size_t)-1); |
1661
566fb4bf7066
Fixes for parsing BODYSTRUCTURE
Timo Sirainen <tss@iki.fi>
parents:
1619
diff
changeset
|
700 ret = imap_parser_finish_line(parser, 0, IMAP_PARSE_FLAG_NO_UNESCAPE | |
566fb4bf7066
Fixes for parsing BODYSTRUCTURE
Timo Sirainen <tss@iki.fi>
parents:
1619
diff
changeset
|
701 IMAP_PARSE_FLAG_LITERAL_TYPE, &args); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
702 ret = ret > 0 && imap_parse_bodystructure_args(args, dest); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
703 |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
704 if (!ret) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
705 i_error("Error parsing IMAP bodystructure: %s", bodystructure); |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
706 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
707 imap_parser_destroy(&parser); |
4070
71b8faa84ec6
Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents:
4027
diff
changeset
|
708 i_stream_destroy(&input); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
709 return ret; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
710 } |