summaryrefslogtreecommitdiff
path: root/mail/escape.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-04-23 23:33:49 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-09-08 16:06:02 +0300
commitd7a596df78be3863fd7a71977e99332eac38bda5 (patch)
treea1a6325961458f41539b9b22571eb817515bce11 /mail/escape.c
parent5124a1e140db914eec9bc1dbe52eb02409ec4acd (diff)
downloadmailutils-d7a596df78be3863fd7a71977e99332eac38bda5.tar.gz
mailutils-d7a596df78be3863fd7a71977e99332eac38bda5.tar.bz2
Stream support rewritten from scratch.
Does not compile yet. New files: * mailbox/streamref.c * include/mailutils/sys/streamref.h * include/mailutils/sys/file_stream.h * include/mailutils/sys/header_stream.h * include/mailutils/sys/mapfile_stream.h * include/mailutils/sys/memory_stream.h * include/mailutils/sys/message_stream.h * include/mailutils/sys/prog_stream.h * include/mailutils/sys/socket_stream.h * include/mailutils/sys/stdio_stream.h * include/mailutils/sys/stream.h * include/mailutils/sys/streamtrans.h * mailbox/prog_stream.c * mailbox/stdio_stream.c * mailbox/stream_printf.c * mailbox/stream_vprintf.c * mailbox/temp_file_stream.c * mailbox/streamcpy.c * mailbox/binflt.c * mailbox/crlfflt.c * mailbox/fltstream.c * mailbox/qpflt.c * mailbox/linelenflt.c Removed files: * mailbox/filter_rfc822.c * mailbox/filter_trans.c Moved files (with edits): * libproto/include/filter0.h -> include/mailutils/sys/filter.h * libproto/include/header0.h -> include/mailutils/sys/header.h * libproto/include/message0.h -> include/mailutils/sys/message.h * libproto/include/mime0.h -> include/mailutils/sys/mime.h Modified files: * comsat/action.c * config/mailutils-config.c * examples/base64.c * examples/cpp/msg-send.cc * examples/header.c * examples/http.c * examples/iconv.c * examples/mimetest.c * examples/msg-send.c * examples/mta.c * examples/murun.c * examples/nntpclient.c * examples/pop3client.c * imap4d/append.c * imap4d/auth_gsasl.c * imap4d/fetch.c * imap4d/preauth.c * imap4d/search.c * imap4d/util.c * include/mailutils/body.h * include/mailutils/folder.h * include/mailutils/header.h * include/mailutils/mailbox.h * include/mailutils/mailer.h * include/mailutils/mailutils.h * include/mailutils/message.h * include/mailutils/stream.h * include/mailutils/sys/Makefile.am * include/mailutils/sys/filter.h * include/mailutils/sys/header.h * include/mailutils/sys/message.h * include/mailutils/sys/mime.h * include/mailutils/sys/nntp.h * include/mailutils/sys/pop3.h * include/mailutils/sys/stream.h * include/mailutils/types.hin * lib/mailcap.c * lib/mu_dbm.h * libmu_argp/muinit.c * libmu_auth/ldap.c * libmu_auth/tls.c * libmu_scm/Makefile.am * libmu_scm/mu_body.c * libmu_scm/mu_message.c * libmu_scm/mu_port.c * libmu_sieve/actions.c * libmu_sieve/extensions/pipe.c * libmu_sieve/extensions/spamd.c * libmu_sieve/extensions/vacation.c * libproto/mailer/smtp.c * libproto/mbox/mboxscan.c * libproto/mbox/mbox.c * libproto/mbox/mbox0.h * libproto/nntp/nntp_article.c * libproto/nntp/nntp_carrier.c * libproto/nntp/nntp_destroy.c * libproto/nntp/nntp_ihave.c * libproto/nntp/nntp_post.c * libproto/nntp/nntp_readline.c * libproto/nntp/nntp_sendline.c * libproto/pop/pop3_carrier.c * libproto/pop/pop3_destroy.c * libproto/pop/pop3_readline.c * libproto/pop/pop3_sendline.c * libproto/pop/pop3_stat.c * maidag/mailtmp.c * mail/decode.c * mail/escape.c * mail/msgset.y * mail/pipe.c * mail/print.c * mail/send.c * mail/top.c * mail/util.c * mail/write.c * mailbox/Makefile.am * mailbox/amd.c * mailbox/attachment.c * mailbox/body.c * mailbox/cfg_driver.c * mailbox/cfg_format.c * mailbox/debug.c * mailbox/file_stream.c * mailbox/folder.c * mailbox/hdritr.c * mailbox/header.c * mailbox/mailbox.c * mailbox/mailcap.c * mailbox/mailer.c * mailbox/mapfile_stream.c * mailbox/memory_stream.c * mailbox/message.c * mailbox/message_stream.c * mailbox/mime.c * mailbox/mimehdr.c * mailbox/mutil.c * mailbox/prog_stream.c * mailbox/progmailer.c * mailbox/rfc2047.c * mailbox/socket_stream.c * mailbox/stream.c * mailbox/stream_vprintf.c * mailbox/tcp.c * mailbox/vartab.c * mailbox/wicket.c * mh/burst.c * mh/comp.c * mh/compcommon.c * mh/forw.c * mh/mh_ctx.c * mh/mh_format.c * mh/mh_init.c * mh/mh_list.c * mh/mh_whatnow.c * mh/mhl.c * mh/mhn.c * mh/pick.y * mh/repl.c * mimeview/mimeview.c * mu-aux/generr.awk * pop3d/extra.c * pop3d/pop3d.h * pop3d/retr.c * pop3d/top.c * readmsg/msglist.c * readmsg/readmsg.c * sieve/sieve.c
Diffstat (limited to 'mail/escape.c')
-rw-r--r--mail/escape.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/mail/escape.c b/mail/escape.c
index 41b7f1b30..c8745143d 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -27,15 +27,21 @@ dump_headers (FILE *fp, compose_env_t *env)
{
char buffer[512];
mu_stream_t stream = NULL;
- size_t off = 0, n;
+ size_t n;
+ int rc;
mu_header_get_stream (env->header, &stream);
- while (mu_stream_read (stream, buffer, sizeof buffer - 1, off, &n) == 0
+ rc = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+ if (rc)
+ {
+ util_error (_("seek error: %s"), mu_stream_strerror (stream, rc));
+ return;
+ }
+ while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
&& n != 0)
{
buffer[n] = 0;
fprintf (fp, "%s", buffer);
- off += n;
}
}
@@ -55,7 +61,7 @@ parse_headers (FILE *fp, compose_env_t *env)
size_t n = 0;
int errcnt = 0, line = 0;
- if ((status = mu_header_create (&header, NULL, 0, NULL)) != 0)
+ if ((status = mu_header_create (&header, NULL, 0)) != 0)
{
util_error (_("Cannot create header: %s"), mu_strerror (status));
return 1;
@@ -139,7 +145,7 @@ parse_headers (FILE *fp, compose_env_t *env)
{
char *p;
- mu_header_destroy (&header, NULL);
+ mu_header_destroy (&header);
p = ml_readline (_("Edit again?"));
if (mu_true_answer_p (p) == 1)
return -1;
@@ -147,7 +153,7 @@ parse_headers (FILE *fp, compose_env_t *env)
return 1;
}
- mu_header_destroy (&env->header, NULL);
+ mu_header_destroy (&env->header);
env->header = header;
return 0;
}
@@ -425,11 +431,11 @@ escape_insert (int argc, char **argv, compose_env_t *send_env MU_ARG_UNUSED)
int
quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
{
+ int rc;
mu_header_t hdr;
mu_body_t body;
mu_stream_t stream;
char buffer[512];
- off_t off = 0;
size_t n = 0;
char *prefix = "\t";
@@ -477,12 +483,18 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
else
mu_message_get_stream (mesg, &stream);
- while (mu_stream_readline (stream, buffer, sizeof buffer - 1, off, &n) == 0
+ rc = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+ if (rc)
+ {
+ util_error (_("seek error: %s"), mu_stream_strerror (stream, rc));
+ return rc;
+ }
+
+ while (mu_stream_readline (stream, buffer, sizeof buffer - 1, &n) == 0
&& n != 0)
{
buffer[n] = '\0';
fprintf (ofile, "%s%s", prefix, buffer);
- off += n;
}
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.