diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-11-11 11:10:49 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-11-11 11:10:49 +0200 |
commit | 499992bf3bbf7e7d3e1203563f856f6db229d73c (patch) | |
tree | e34d7f1c16bef5ce978fe40a35f41abea5a3f49f /tests/nullmail.c | |
parent | ba1c15e2290246d272037404c46f44abd9d98c0e (diff) | |
download | wydawca-499992bf3bbf7e7d3e1203563f856f6db229d73c.tar.gz wydawca-499992bf3bbf7e7d3e1203563f856f6db229d73c.tar.bz2 |
Fix build with mailutils 3.4
* Makefile.am (ACLOCAL_AMFLAGS): Add am.
* NEWS: Update.
* am/mailutils.m4: New file. A fixed version of upstream mailutils.m4
* configure.ac: Require mailutils 3.3. Raise patchlevel.
* tests/nullmail.c: New file.
* tests/.gitignore: Add nullmail
* tests/Makefile.am: Build nullmail
* tests/etc/nullmail: Remove
* tests/etc/Makefile.am: Remove nullmail script.
* tests/atlocal.in (WY_TESTDIR): New variable.
* tests/check-notify.at: Use new nullmail tool. Update expected
output.
* tests/mailstats.at: Likewise.
* tests/notify-upl.at: Likewise.
* tests/etc/mailstats.rcin: Fix mailer command line.
* tests/etc/notify.rcin: Likewise.
Diffstat (limited to 'tests/nullmail.c')
-rw-r--r-- | tests/nullmail.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/nullmail.c b/tests/nullmail.c new file mode 100644 index 0000000..4c5bb9d --- /dev/null +++ b/tests/nullmail.c @@ -0,0 +1,84 @@ +#include <mailutils/mailutils.h> + +char const *headers[] = { + MU_HEADER_FROM, + MU_HEADER_TO, + MU_HEADER_SUBJECT, + NULL +}; + +char *output_name; +char *sender_email; + +static struct mu_option nullmail_options[] = { + { "output", 'o', "FILE", MU_OPTION_DEFAULT, + "dump mail to file", + mu_c_string, &output_name }, + { "from", 'F', "EMAIL", MU_OPTION_DEFAULT, + "sender email address", + mu_c_string, &sender_email }, + MU_OPTION_END +}, *options[] = { nullmail_options, NULL }; + +struct mu_cli_setup cli = { + options, + NULL, + "null mailer", + NULL +}; + +char *capa[] = { + "debug", + NULL +}; + +int +main (int argc, char **argv) +{ + int i, rc; + mu_message_t msg; + mu_stream_t input, output, str; + mu_header_t hdr; + mu_body_t body; + + mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); + /* FIXME: non-option arguments are silently ignored */ + if (output_name) + MU_ASSERT (mu_file_stream_create (&output, output_name, + MU_STREAM_CREAT|MU_STREAM_APPEND)); + else + { + output = mu_strout; + mu_stream_ref (output); + } + + if (sender_email) + mu_stream_printf (output, "From %s\n", sender_email); + + MU_ASSERT (mu_temp_file_stream_create (&input, NULL, 0)); + MU_ASSERT (mu_stream_copy (input, mu_strin, 0, NULL)); + MU_ASSERT (mu_stream_to_message (input, &msg)); + MU_ASSERT (mu_message_get_header (msg, &hdr)); + for (i = 0; headers[i]; i++) + { + char *val; + rc = mu_header_aget_value_unfold (hdr, headers[i], &val); + if (rc == 0) + { + mu_stream_printf (output, "%s: %s\n", headers[i], val); + free (val); + } + else if (rc != MU_ERR_NOENT) + mu_diag_funcall (MU_DIAG_ERROR, "mu_header_get_value_unfold", + headers[i], rc); + } + mu_stream_printf (output, "\n"); + MU_ASSERT (mu_message_get_body (msg, &body)); + MU_ASSERT (mu_body_get_streamref (body, &str)); + MU_ASSERT (mu_stream_copy (output, str, 0, NULL)); + + mu_stream_close (output); + + return 0; +} + |