(mu_stream_printf): Remove
(mime_create_ds): Bugfix: datestr was never initialized! Nobody noticed this far?
Showing
1 changed file
with
27 additions
and
25 deletions
... | @@ -82,27 +82,6 @@ sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -82,27 +82,6 @@ sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
82 | } | 82 | } |
83 | 83 | ||
84 | int | 84 | int |
85 | mu_stream_printf (mu_stream_t stream, size_t *off, const char *fmt, ...) | ||
86 | { | ||
87 | va_list ap; | ||
88 | char *buf = NULL; | ||
89 | size_t size, bytes; | ||
90 | int rc; | ||
91 | |||
92 | va_start (ap, fmt); | ||
93 | vasprintf (&buf, fmt, ap); | ||
94 | va_end (ap); | ||
95 | size = strlen (buf); | ||
96 | rc = mu_stream_write (stream, buf, size, *off, &bytes); | ||
97 | if (rc) | ||
98 | return rc; | ||
99 | *off += bytes; | ||
100 | if (bytes != size) | ||
101 | return EIO; | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | int | ||
106 | mu_sieve_get_message_sender (mu_message_t msg, char **ptext) | 85 | mu_sieve_get_message_sender (mu_message_t msg, char **ptext) |
107 | { | 86 | { |
108 | int rc; | 87 | int rc; |
... | @@ -131,7 +110,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) | ... | @@ -131,7 +110,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) |
131 | time_t t; | 110 | time_t t; |
132 | struct tm *tm; | 111 | struct tm *tm; |
133 | char *sender; | 112 | char *sender; |
134 | size_t off = 0; | 113 | mu_off_t off = 0; |
135 | mu_body_t body; | 114 | mu_body_t body; |
136 | mu_header_t hdr; | 115 | mu_header_t hdr; |
137 | char datestr[80]; | 116 | char datestr[80]; |
... | @@ -165,15 +144,20 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) | ... | @@ -165,15 +144,20 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) |
165 | } | 144 | } |
166 | 145 | ||
167 | static void | 146 | static void |
168 | mime_create_ds (mu_mime_t mime) | 147 | mime_create_ds (mu_mime_t mime, mu_message_t orig) |
169 | { | 148 | { |
170 | mu_message_t newmsg; | 149 | mu_message_t newmsg; |
171 | mu_stream_t stream; | 150 | mu_stream_t stream; |
172 | mu_header_t hdr; | 151 | mu_header_t hdr; |
173 | size_t off = 0; | 152 | mu_off_t off = 0; |
174 | mu_body_t body; | 153 | mu_body_t body; |
175 | char *email; | 154 | char *email; |
176 | char datestr[80]; | 155 | char datestr[80]; |
156 | time_t t = time (NULL); | ||
157 | struct tm tm, *tmp; | ||
158 | mu_timezone tz; | ||
159 | mu_envelope_t env; | ||
160 | const char *p; | ||
177 | 161 | ||
178 | mu_message_create (&newmsg, NULL); | 162 | mu_message_create (&newmsg, NULL); |
179 | mu_message_get_header (newmsg, &hdr); | 163 | mu_message_get_header (newmsg, &hdr); |
... | @@ -181,7 +165,20 @@ mime_create_ds (mu_mime_t mime) | ... | @@ -181,7 +165,20 @@ mime_create_ds (mu_mime_t mime) |
181 | mu_message_get_body (newmsg, &body); | 165 | mu_message_get_body (newmsg, &body); |
182 | mu_body_get_stream (body, &stream); | 166 | mu_body_get_stream (body, &stream); |
183 | mu_stream_printf (stream, &off, "Reporting-UA: sieve; %s\n", PACKAGE_STRING); | 167 | mu_stream_printf (stream, &off, "Reporting-UA: sieve; %s\n", PACKAGE_STRING); |
168 | |||
169 | mu_message_get_envelope (orig, &env); | ||
170 | if (mu_envelope_sget_date (env, &p) == 0 | ||
171 | && mu_parse_ctime_date_time (&p, &tm, &tz) == 0) | ||
172 | t = mu_tm2time (&tm, &tz); | ||
173 | else | ||
174 | /* Use local time instead */ | ||
175 | t = time (NULL); | ||
176 | tmp = localtime (&t); | ||
177 | |||
178 | /* FIXME: timezone info is lost */ | ||
179 | mu_strftime (datestr, sizeof datestr, "%a, %b %d %H:%M:%S %Y %Z", tmp); | ||
184 | mu_stream_printf (stream, &off, "Arrival-Date: %s\n", datestr); | 180 | mu_stream_printf (stream, &off, "Arrival-Date: %s\n", datestr); |
181 | |||
185 | email = mu_get_user_email (NULL); | 182 | email = mu_get_user_email (NULL); |
186 | mu_stream_printf (stream, &off, "Final-Recipient: RFC822; %s\n", | 183 | mu_stream_printf (stream, &off, "Final-Recipient: RFC822; %s\n", |
187 | email ? email : "unknown"); | 184 | email ? email : "unknown"); |
... | @@ -189,7 +186,12 @@ mime_create_ds (mu_mime_t mime) | ... | @@ -189,7 +186,12 @@ mime_create_ds (mu_mime_t mime) |
189 | mu_stream_printf (stream, &off, "Action: deleted\n"); | 186 | mu_stream_printf (stream, &off, "Action: deleted\n"); |
190 | mu_stream_printf (stream, &off, | 187 | mu_stream_printf (stream, &off, |
191 | "Disposition: automatic-action/MDN-sent-automatically;deleted\n"); | 188 | "Disposition: automatic-action/MDN-sent-automatically;deleted\n"); |
189 | |||
190 | t = time (NULL); | ||
191 | tmp = localtime (&t); | ||
192 | mu_strftime (datestr, sizeof datestr, "%a, %b %d %H:%M:%S %Y %Z", tmp); | ||
192 | mu_stream_printf (stream, &off, "Last-Attempt-Date: %s\n", datestr); | 193 | mu_stream_printf (stream, &off, "Last-Attempt-Date: %s\n", datestr); |
194 | |||
193 | mu_stream_close (stream); | 195 | mu_stream_close (stream); |
194 | mu_mime_add_part(mime, newmsg); | 196 | mu_mime_add_part(mime, newmsg); |
195 | mu_message_unref (newmsg); | 197 | mu_message_unref (newmsg); |
... | @@ -238,7 +240,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text) | ... | @@ -238,7 +240,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text) |
238 | 240 | ||
239 | mu_mime_create (&mime, NULL, 0); | 241 | mu_mime_create (&mime, NULL, 0); |
240 | mime_create_reason (mime, msg, text); | 242 | mime_create_reason (mime, msg, text); |
241 | mime_create_ds (mime); | 243 | mime_create_ds (mime, msg); |
242 | status = mime_create_quote (mime, msg); | 244 | status = mime_create_quote (mime, msg); |
243 | if (status) | 245 | if (status) |
244 | { | 246 | { | ... | ... |
-
Please register or sign in to post a comment