Commit ada8b8cf ada8b8cfa6957d99831c7318e572628006b1ca66 by Sergey Poznyakoff

Use UTC in From_ separators in accordance with RFC 4155.

* examples/mta.c (make_tmp): Use gmtime + mu_c_streamftime to
create From_ line.
* libmailutils/mailbox/msgenv.c (message_envelope_date): Use gmtime.
* maidag/deliver.c (make_tmp): Likewise.
* maidag/lmtp.c (cfun_data): Likewise.
* readmsg/readmsg.c (print_unix_header): Use gmtime.
1 parent 76cc3308
...@@ -222,6 +222,7 @@ make_tmp (mu_stream_t in) ...@@ -222,6 +222,7 @@ make_tmp (mu_stream_t in)
222 if (n >= 5 && memcmp (buf, "From ", 5)) 222 if (n >= 5 && memcmp (buf, "From ", 5))
223 { 223 {
224 time_t t; 224 time_t t;
225 struct tm *tm;
225 const char *from = from_address (); 226 const char *from = from_address ();
226 if (!from) 227 if (!from)
227 { 228 {
...@@ -230,7 +231,9 @@ make_tmp (mu_stream_t in) ...@@ -230,7 +231,9 @@ make_tmp (mu_stream_t in)
230 } 231 }
231 232
232 time (&t); 233 time (&t);
233 mu_stream_printf (out, "From %s %s", from, ctime (&t)); 234 tm = gmtime (&t);
235 mu_stream_printf (out, "From %s ", from);
236 mu_c_streamftime (out, "%c%n", tm, NULL);
234 } 237 }
235 238
236 mu_stream_write (out, buf, n, NULL); 239 mu_stream_write (out, buf, n, NULL);
......
...@@ -57,7 +57,7 @@ message_envelope_date (mu_envelope_t envelope, char *buf, size_t len, ...@@ -57,7 +57,7 @@ message_envelope_date (mu_envelope_t envelope, char *buf, size_t len,
57 char tmpbuf[MU_DATETIME_FROM_LENGTH+1]; 57 char tmpbuf[MU_DATETIME_FROM_LENGTH+1];
58 t = time (NULL); 58 t = time (NULL);
59 n = mu_strftime (tmpbuf, sizeof tmpbuf, 59 n = mu_strftime (tmpbuf, sizeof tmpbuf,
60 MU_DATETIME_FROM, localtime (&t)); 60 MU_DATETIME_FROM, gmtime (&t));
61 n = mu_cpystr (buf, tmpbuf, len); 61 n = mu_cpystr (buf, tmpbuf, len);
62 } 62 }
63 if (pnwrite) 63 if (pnwrite)
......
...@@ -1536,11 +1536,8 @@ imap_envelope_date (mu_envelope_t envelope, char *buffer, size_t buflen, ...@@ -1536,11 +1536,8 @@ imap_envelope_date (mu_envelope_t envelope, char *buffer, size_t buflen,
1536 parsed, use the calendar time. */ 1536 parsed, use the calendar time. */
1537 if (now == (time_t)-1) 1537 if (now == (time_t)-1)
1538 { 1538 {
1539 struct tm *gmt;
1540
1541 time (&now); 1539 time (&now);
1542 gmt = gmtime (&now); 1540 tm = *gmtime (&now);
1543 tm = *gmt;
1544 } 1541 }
1545 1542
1546 { 1543 {
......
...@@ -69,9 +69,12 @@ make_tmp (const char *from) ...@@ -69,9 +69,12 @@ make_tmp (const char *from)
69 if (from) 69 if (from)
70 { 70 {
71 time_t t; 71 time_t t;
72 struct tm *tm;
72 73
73 time (&t); 74 time (&t);
74 mu_stream_printf (out, "From %s %s", from, ctime (&t)); 75 tm = gmtime (&t);
76 mu_stream_printf (out, "From %s ", from);
77 mu_c_streamftime (out, "%c%n", tm, NULL);
75 } 78 }
76 else 79 else
77 { 80 {
......
...@@ -346,6 +346,7 @@ cfun_data (mu_stream_t iostr, char *arg) ...@@ -346,6 +346,7 @@ cfun_data (mu_stream_t iostr, char *arg)
346 int rc; 346 int rc;
347 mu_stream_t flt, tempstr; 347 mu_stream_t flt, tempstr;
348 time_t t; 348 time_t t;
349 struct tm *tm;
349 int xlev = MU_XSCRIPT_PAYLOAD, xlev_switch = 0, buf_switch = 0; 350 int xlev = MU_XSCRIPT_PAYLOAD, xlev_switch = 0, buf_switch = 0;
350 struct mu_buffer_query oldbuf; 351 struct mu_buffer_query oldbuf;
351 352
...@@ -375,7 +376,10 @@ cfun_data (mu_stream_t iostr, char *arg) ...@@ -375,7 +376,10 @@ cfun_data (mu_stream_t iostr, char *arg)
375 376
376 /* Write out envelope */ 377 /* Write out envelope */
377 time (&t); 378 time (&t);
378 rc = mu_stream_printf (tempstr, "From %s %s", mail_from, ctime (&t)); 379 tm = gmtime (&t);
380 rc = mu_stream_printf (tempstr, "From %s ", mail_from);
381 if (rc == 0)
382 rc = mu_c_streamftime (tempstr, "%c%n", tm, NULL);
379 if (rc) 383 if (rc)
380 { 384 {
381 maidag_error (_("copy error: %s"), mu_strerror (rc)); 385 maidag_error (_("copy error: %s"), mu_strerror (rc));
......
...@@ -184,7 +184,7 @@ print_unix_header (mu_message_t message) ...@@ -184,7 +184,7 @@ print_unix_header (mu_message_t message)
184 struct tm *tm; 184 struct tm *tm;
185 185
186 t = time (NULL); 186 t = time (NULL);
187 tm = localtime (&t); 187 tm = gmtime (&t);
188 mu_strftime (datebuf, sizeof datebuf, MU_DATETIME_FROM, tm); 188 mu_strftime (datebuf, sizeof datebuf, MU_DATETIME_FROM, tm);
189 buf = datebuf; 189 buf = datebuf;
190 } 190 }
......