Commit c522de11 c522de119a265c25c7ea6a269c02eaa80cdc9e49 by Sergey Poznyakoff

sieve: bugfixes

* include/mailutils/sieve.h (mu_sieve_debug_handle): New declaration.
(mu_sieve_debug_init): New prototype.
* libmu_sieve/conf.c (mu_sieve_debug_handle): New global.
(mu_sieve_module_init): Call mu_sieve_debug_init.
* libmu_sieve/extensions/spamd.c (spamd_connect_tcp)
(spamd_connect_socket): Fix stream creation.
(spamd_send_message): Switch to full buffering on the transport
stream and indicate it is a payload (in case transcript is enabled),
before copying data.  Restore things to their original state afterwards.
(spamd_read_line): Rewrite using mu_stream_getline.
(decode_float): Additional argument endp. Unless NULL, store there the
position in the input string where the parsing has stopped.
(parse_response_line): New function.
(spamd_test): Rewrite using new API.
* sieve/sieve.c (parser): --dry-run implies --verbose.

* libmailutils/filter/base64.c (_base64_decoder): when not enough data
are available and cmd is not mu_filter_lastbuf, return mu_filter_lastbuf.
* libmailutils/stream/stream.c (mu_stream_shutdown): Flush the buffers before
shutting the transport down.

* libmailutils/tests/fltst.c (main): New option bufsize=
1 parent e3a1f604
......@@ -82,7 +82,7 @@ usage (const char *diag)
fp = stdout;
fprintf (fp, "%s",
"usage: fltst FILTER {encode|decode} {read|write} [shift=N] [verbose] [printable] [nl] [-- args]\n");
"usage: fltst FILTER {encode|decode} {read|write} [shift=N] [verbose] [printable] [nl] [bufsize=N] [-- args]\n");
exit (diag ? 1 : 0);
}
......@@ -96,6 +96,7 @@ main (int argc, char * argv [])
char *fltname;
mu_off_t shift = 0;
int newline_option = 0;
size_t bufsize = 0;
if (argc == 1)
usage (NULL);
......@@ -122,6 +123,8 @@ main (int argc, char * argv [])
{
if (strncmp (argv[i], "shift=", 6) == 0)
shift = strtoul (argv[i] + 6, NULL, 0);
else if (strncmp (argv[i], "bufsize=", 8) == 0)
bufsize = strtoul (argv[i] + 8, NULL, 0);
else if (strcmp (argv[i], "verbose") == 0)
verbose++;
else if (strcmp (argv[i], "printable") == 0)
......@@ -141,6 +144,8 @@ main (int argc, char * argv [])
argv += i;
MU_ASSERT (mu_stdio_stream_create (&in, MU_STDIN_FD, 0));
if (bufsize)
mu_stream_set_buffer (in, mu_buffer_full, bufsize);
MU_ASSERT (mu_stdio_stream_create (&out, MU_STDOUT_FD, 0));
if (flags == MU_STREAM_READ)
......@@ -150,6 +155,8 @@ main (int argc, char * argv [])
mode,
MU_STREAM_READ|MU_STREAM_SEEK));
mu_stream_unref (in);
if (bufsize)
mu_stream_set_buffer (flt, mu_buffer_full, bufsize);
if (shift)
MU_ASSERT (mu_stream_seek (flt, shift, MU_SEEK_SET, NULL));
c_copy (out, flt);
......@@ -160,6 +167,8 @@ main (int argc, char * argv [])
argc, (const char **)argv,
mode,
MU_STREAM_WRITE));
if (bufsize)
mu_stream_set_buffer (flt, mu_buffer_full, bufsize);
if (shift)
MU_ASSERT (mu_stream_seek (in, shift, MU_SEEK_SET, NULL));
c_copy (flt, in);
......