Commit 0bf8123e 0bf8123e1c49fc4ac4383ff95e26f486d6b8948b by Sergey Poznyakoff

Improve mta simulator output.

* examples/mta.c (mta_send): A line number refers to the start
of each line, not end of it.
* mail/testsuite/mail/send.exp: Reflect this change.
* sieve/tests/redirect.at: Likewise.
* sieve/tests/reject.at: Likewise.
1 parent 20bcdece
......@@ -326,6 +326,7 @@ mta_send (mu_message_t msg)
mu_stream_t stream = NULL;
size_t line;
char *value;
int newline = 0;
value = from_address ();
if (value)
......@@ -340,7 +341,7 @@ mta_send (mu_message_t msg)
mu_message_get_streamref (msg, &stream);
line = 0;
fprintf (diag, "%4lu: ", (unsigned long) line);
newline = 1;
while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
&& n != 0)
{
......@@ -348,16 +349,23 @@ mta_send (mu_message_t msg)
for (i = 0; i < n; i++)
{
if (newline)
{
fprintf (diag, "%4lu: ", (unsigned long) line);
newline = 0;
}
fputc (buffer[i], diag);
if (buffer[i] == '\n')
{
line++;
fprintf (diag, "%4lu: ", (unsigned long) line);
newline = 1;
}
}
}
mu_stream_destroy (&stream);
fprintf (diag, "\nEND OF MESSAGE\n");
if (!newline)
fprintf (diag, "\n(no newline at EOF)\n");
fprintf (diag, "END OF MESSAGE\n");
fflush (diag);
return 0;
}
......
......@@ -52,7 +52,6 @@ ENVELOPE TO: <gray@gnu.org>
13:
14: --
15: Wile E. Coyote "Super Genius" coyote@desert.example.org
16:
END OF MESSAGE
ENVELOPE FROM: b1ff@de.res.example.com
ENVELOPE TO: <gray@gnu.org>
......@@ -70,7 +69,6 @@ ENVELOPE TO: <gray@gnu.org>
11: $20,000 IN LESS THAN TWO MONTHS! AND IT'S LEGAL!!!!!!!!!
12: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1 JUST
13: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
14:
END OF MESSAGE
ENVELOPE FROM: bar@dontmailme.org
ENVELOPE TO: <gray@gnu.org>
......@@ -85,7 +83,6 @@ ENVELOPE TO: <gray@gnu.org>
8: Subject: Coffee
9:
10: How about some coffee?
11:
END OF MESSAGE
],
[REDIRECT on msg uid 1: to gray@gnu.org
......
......@@ -100,7 +100,6 @@ ENVELOPE TO: <coyote@desert.example.org>
43: Wile E. Coyote "Super Genius" coyote@desert.example.org
44:
45: --(boundary)
46:
END OF MESSAGE
ENVELOPE FROM: MAILER-DAEMON@nonexistent.net
ENVELOPE TO: <b1ff@de.res.example.com>
......@@ -148,7 +147,6 @@ ENVELOPE TO: <b1ff@de.res.example.com>
41: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
42:
43: --(boundary)
44:
END OF MESSAGE
ENVELOPE FROM: MAILER-DAEMON@nonexistent.net
ENVELOPE TO: <bar@dontmailme.org>
......@@ -193,7 +191,6 @@ ENVELOPE TO: <bar@dontmailme.org>
38: How about some coffee?
39:
40: --(boundary)
41:
END OF MESSAGE
],
[REJECT on msg uid 1
......