From 383f245d39b8b806a4b6ce4dea7b0ab7f1658450 Mon Sep 17 00:00:00 2001 From: NotZed Date: Thu, 20 Apr 2000 23:48:45 +0000 Subject: MERGE NEW_PARSER branch into HEAD, fixed conflicts. 2000-04-20 NotZed * MERGE NEW_PARSER branch into HEAD, fixed conflicts. * gmime-content-field.c (_print_parameter): Duh, removed again (@@#$@ cvs merge). * camel-mime-utils.c (header_content_type_is): Constify. (header_content_type_unref): Killed a couple warnings. * camel-folder.c (_init): Removed more log crap. * providers/Makefile.am (SUBDIRS): Removed nntp, pending fixes for summary changes. * providers/mbox/camel-mbox-folder.c (_get_message_by_number): Fixed for new summary interface. Added a warning for using this broken api. (_get_message_by_uid): Fixed for message new with session vanishing. svn path=/trunk/; revision=2531 --- camel/camel-stream.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'camel/camel-stream.c') diff --git a/camel/camel-stream.c b/camel/camel-stream.c index 4e7a6c640c..aaa782620e 100644 --- a/camel/camel-stream.c +++ b/camel/camel-stream.c @@ -242,3 +242,45 @@ camel_stream_write_strings (CamelStream *stream, ... ) } va_end (args); } + +/** + * camel_stream_write_to_stream: + * @stream: Source CamelStream. + * @output_stream: Destination CamelStream. + * + * Write all of a stream (until eos) into another stream, in a blocking + * fashion. + * + * FIXME: This really needs to return an error code. + **/ +void +camel_stream_write_to_stream (CamelStream *stream, + CamelStream *output_stream) +{ + gchar tmp_buf[4096]; + gint nb_read; + gint nb_written; + + /* + * default implementation that uses the input + * stream and stream it in a blocking way + * to an output stream. + */ + g_assert (output_stream); + g_assert (stream); + + while (!camel_stream_eos (CAMEL_STREAM (stream))) { + nb_read = camel_stream_read (CAMEL_STREAM (stream), tmp_buf, 4096); + if (nb_read>0) { + nb_written = 0; + + while (nb_written < nb_read) { + int len = camel_stream_write (output_stream, tmp_buf + nb_written, nb_read - nb_written); + /* FIXME: what about length 0? */ + if (len<0) + return; + nb_written += len; + } + } + } +} -- cgit