diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-07 13:23:45 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-07 13:23:45 +0300 |
commit | dd8d091ba3cae58fd437c664478de8bcbdf25ac6 (patch) | |
tree | 8ffdc4ca5a4a05808d247a69ca87635a9f92a71a /libproto/mbox/mbox.c | |
parent | f24df125b4a5f7e29eee39e89127871a38856281 (diff) | |
download | mailutils-dd8d091ba3cae58fd437c664478de8bcbdf25ac6.tar.gz mailutils-dd8d091ba3cae58fd437c664478de8bcbdf25ac6.tar.bz2 |
Implement a filter for quoting ^From. Use it for appending to UNIX mailboxes.
* libmailutils/fromflt.c: New file.
* libmailutils/Makefile.am (libmailutils_la_SOURCES): Add fromflt.c
* libmailutils/tests/testsuite.at: Include fromflt.at.
* include/mailutils/filter.h (mu_from_filter): New filter type.
* libmailutils/filter.c (mu_filter_get_list): Register mu_from_filter.
* libmailutils/fromflt.at: New file.
* libmailutils/tests/Makefile.am (TESTSUITE_AT): Add fromflt.at.
* libmailutils/tests/base64d.at: Mention `filter' in the keywords.
* libmailutils/tests/base64e.at: Likewise.
* libmailutils/tests/fltst.c (main): Fix argc check.
* libproto/mbox/mbox.c (append_message_to_stream): Use "FROM" filter.
Diffstat (limited to 'libproto/mbox/mbox.c')
-rw-r--r-- | libproto/mbox/mbox.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c index 62507657e..cc412ff37 100644 --- a/libproto/mbox/mbox.c +++ b/libproto/mbox/mbox.c @@ -25,12 +25,13 @@ # include <config.h> #endif #include <mbox0.h> #include <mailutils/cstr.h> #include <mailutils/io.h> +#include <mailutils/filter.h> #define ATTRIBUTE_IS_DELETED(flag) (flag & MU_ATTRIBUTE_DELETED) #define ATTRIBUTE_IS_EQUAL(flag1, flag2) (flag1 == flag2) static int mbox_is_updated (mu_mailbox_t mailbox); static int mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted); @@ -1030,13 +1031,13 @@ uid_to_stream (mu_stream_t ostr, mu_message_t msg, mbox_data_t mud, int flags) /* Append MSG to stream OSTR in its current position */ static int append_message_to_stream (mu_stream_t ostr, mu_message_t msg, mbox_data_t mud, int flags) { int status; - mu_stream_t istr; + mu_stream_t istr, flt; status = msg_envelope_to_stream (ostr, msg); if (status) return status; if (flags & MBOX_EXPUNGE) @@ -1081,16 +1082,24 @@ append_message_to_stream (mu_stream_t ostr, mu_message_t msg, else { status = mu_message_get_streamref (msg, &istr); if (status) return status; } - status = mu_stream_copy (ostr, istr, 0, NULL); - mu_stream_destroy (&istr); + + status = mu_filter_create (&flt, istr, "FROM", + MU_FILTER_ENCODE, MU_STREAM_READ); + mu_stream_unref (istr); if (status == 0) - status = mu_stream_write (ostr, "\n", 1, NULL); + { + status = mu_stream_copy (ostr, flt, 0, NULL); + mu_stream_destroy (&flt); + if (status == 0) + status = mu_stream_write (ostr, "\n", 1, NULL); + } + return status; } static int mbox_append_message (mu_mailbox_t mailbox, mu_message_t msg) { |