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)
if (n >= 5 && memcmp (buf, "From ", 5))
{
time_t t;
struct tm *tm;
const char *from = from_address ();
if (!from)
{
......@@ -230,7 +231,9 @@ make_tmp (mu_stream_t in)
}
time (&t);
mu_stream_printf (out, "From %s %s", from, ctime (&t));
tm = gmtime (&t);
mu_stream_printf (out, "From %s ", from);
mu_c_streamftime (out, "%c%n", tm, NULL);
}
mu_stream_write (out, buf, n, NULL);
......
......@@ -57,7 +57,7 @@ message_envelope_date (mu_envelope_t envelope, char *buf, size_t len,
char tmpbuf[MU_DATETIME_FROM_LENGTH+1];
t = time (NULL);
n = mu_strftime (tmpbuf, sizeof tmpbuf,
MU_DATETIME_FROM, localtime (&t));
MU_DATETIME_FROM, gmtime (&t));
n = mu_cpystr (buf, tmpbuf, len);
}
if (pnwrite)
......
......@@ -1536,11 +1536,8 @@ imap_envelope_date (mu_envelope_t envelope, char *buffer, size_t buflen,
parsed, use the calendar time. */
if (now == (time_t)-1)
{
struct tm *gmt;
time (&now);
gmt = gmtime (&now);
tm = *gmt;
tm = *gmtime (&now);
}
{
......
......@@ -69,9 +69,12 @@ make_tmp (const char *from)
if (from)
{
time_t t;
struct tm *tm;
time (&t);
mu_stream_printf (out, "From %s %s", from, ctime (&t));
tm = gmtime (&t);
mu_stream_printf (out, "From %s ", from);
mu_c_streamftime (out, "%c%n", tm, NULL);
}
else
{
......
......@@ -346,6 +346,7 @@ cfun_data (mu_stream_t iostr, char *arg)
int rc;
mu_stream_t flt, tempstr;
time_t t;
struct tm *tm;
int xlev = MU_XSCRIPT_PAYLOAD, xlev_switch = 0, buf_switch = 0;
struct mu_buffer_query oldbuf;
......@@ -375,7 +376,10 @@ cfun_data (mu_stream_t iostr, char *arg)
/* Write out envelope */
time (&t);
rc = mu_stream_printf (tempstr, "From %s %s", mail_from, ctime (&t));
tm = gmtime (&t);
rc = mu_stream_printf (tempstr, "From %s ", mail_from);
if (rc == 0)
rc = mu_c_streamftime (tempstr, "%c%n", tm, NULL);
if (rc)
{
maidag_error (_("copy error: %s"), mu_strerror (rc));
......
......@@ -184,7 +184,7 @@ print_unix_header (mu_message_t message)
struct tm *tm;
t = time (NULL);
tm = localtime (&t);
tm = gmtime (&t);
mu_strftime (datebuf, sizeof datebuf, MU_DATETIME_FROM, tm);
buf = datebuf;
}
......