aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream.c
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-05-20 03:58:41 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-20 03:58:41 +0800
commit2ce4eb74b65f3e9d07a921aad3899a7141b0000f (patch)
tree50439e412a6f12dc0b7db68274de8a8f16b74e08 /camel/camel-stream.c
parentb5ae6150b2a72683b7311af3252230069300d9e2 (diff)
downloadgsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar.gz
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar.bz2
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar.lz
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar.xz
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.tar.zst
gsoc2013-evolution-2ce4eb74b65f3e9d07a921aad3899a7141b0000f.zip
> searchpart = strchr(namepart, '?');
2000-05-19 NotZed <NotZed@HelixCode.com> * camel-simple-data-wrapper.c (construct_from_stream): If we already have been constructed, unref our content. (write_to_stream): Check we've been constructued, and change for stream api changes. * camel-mime-parser.c: Removed exception stuff. * md5-utils.c (md5_get_digest_from_stream): repaired. * camel-mime-message.c: Remove exception from write_to_stream, and fix, and fix formatting. * providers/sendmail/camel-sendmail-transport.c (_send_internal): Fix for stream changes. * providers/pop3/camel-pop3-store.c (camel_pop3_command): Fixes for stream changes. * providers/mbox/camel-mbox-folder.c, and elsewhere, fix all stream api changes. (mbox_append_message): Use stream_close() now its back. (mbox_append_message): unref the from filter. * camel-stream-mem.c: And here. * camel-stream-fs.[ch]: Here too. * camel-stream-filter.c: Likewise. This is getting tedious. * camel-stream-buffer.c (stream_write): Fix a few little problems. (stream_close): Reimplmeent. (camel_stream_buffer_read_line): Slightly more efficient version, that also only allocates the right amount of memory for strings. * camel-seekable-substream.c: Likewise. * camel-seekable-stream.[ch]: Remove exceptions, fix formatting, changes for stream (re)fixes. set_bounds returns an error. * camel-stream.[ch]: Remove exceptions. Make flush and reset return an error code, repair all the screwed up formatting, and put back close. * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): And here. * camel-mime-part.c (camel_mime_part_set_content): And this too. (write_to_stream): Fixed for stream changes. * camel.h: Fixed. * providers/vee/camel-vee-folder.c (vee_search_by_expression): Implement. Performs an intersection of the two searches. (camel_vee_folder_finalise): Unref search folders. (vee_append_message): Implement append. svn path=/trunk/; revision=3142
Diffstat (limited to 'camel/camel-stream.c')
-rw-r--r--camel/camel-stream.c107
1 files changed, 62 insertions, 45 deletions
diff --git a/camel/camel-stream.c b/camel/camel-stream.c
index 07578a7848..244b6cf9d8 100644
--- a/camel/camel-stream.c
+++ b/camel/camel-stream.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
/* camel-stream.c : abstract class for a stream */
/*
@@ -31,7 +31,8 @@ static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelStream */
#define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass)
-static void stream_flush (CamelStream *stream, CamelException *ex);
+static int stream_flush (CamelStream *stream);
+static int stream_close (CamelStream *stream);
static gboolean stream_eos (CamelStream *stream);
@@ -42,6 +43,7 @@ camel_stream_class_init (CamelStreamClass *camel_stream_class)
/* virtual method definition */
camel_stream_class->flush = stream_flush;
+ camel_stream_class->close = stream_close;
camel_stream_class->eos = stream_eos;
}
@@ -75,22 +77,20 @@ camel_stream_get_type (void)
* @stream: a CamelStream.
* @buffer: buffer where bytes pulled from the stream are stored.
* @n: max number of bytes to read.
- * @ex: a CamelException
*
* Read at most @n bytes from the @stream object and stores them
* in the buffer pointed at by @buffer.
*
- * Return value: number of bytes actually read. If an error occurs,
- * @ex will contain a description of the error.
+ * Return value: number of bytes actually read, or -1 on error and
+ * set errno.
**/
int
-camel_stream_read (CamelStream *stream, char *buffer, unsigned int n,
- CamelException *ex)
+camel_stream_read (CamelStream *stream, char *buffer, unsigned int n)
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
g_return_val_if_fail (n == 0 || buffer, -1);
- return CS_CLASS (stream)->read (stream, buffer, n, ex);
+ return CS_CLASS (stream)->read (stream, buffer, n);
}
/**
@@ -98,44 +98,68 @@ camel_stream_read (CamelStream *stream, char *buffer, unsigned int n,
* @stream: a CamelStream object.
* @buffer: buffer to write.
* @n: number of bytes to write
- * @ex: a CamelException
*
* Write @n bytes from the buffer pointed at by @buffer into @stream.
*
- * Return value: the number of bytes actually written to the stream. If
- * an error occurs, @ex will contain a description of the error.
+ * Return value: the number of bytes actually written to the stream,
+ * or -1 on error.
**/
int
-camel_stream_write (CamelStream *stream, const char *buffer, unsigned int n,
- CamelException *ex)
+camel_stream_write (CamelStream *stream, const char *buffer, unsigned int n)
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
g_return_val_if_fail (n == 0 || buffer, -1);
- return CS_CLASS (stream)->write (stream, buffer, n, ex);
+ return CS_CLASS (stream)->write (stream, buffer, n);
}
-static void
-stream_flush (CamelStream *stream, CamelException *ex)
+static int
+stream_flush (CamelStream *stream)
{
/* nothing */
+ return 0;
}
/**
* camel_stream_flush:
* @stream: a CamelStream object
- * @ex: a CamelException
*
* Flushes the contents of the stream to its backing store. Only meaningful
- * on writable streams. If an error occurs, @ex will be set.
+ * on writable streams.
+ *
+ * Return value: -1 on error.
+ **/
+int
+camel_stream_flush (CamelStream *stream)
+{
+ g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
+
+ return CS_CLASS (stream)->flush (stream);
+}
+
+
+static int
+stream_close (CamelStream *stream)
+{
+ /* nothing */
+ return 0;
+}
+
+/**
+ * camel_stream_close:
+ * @stream:
+ *
+ * Close a stream.
+ *
+ * Return value: -1 on error.
**/
-void
-camel_stream_flush (CamelStream *stream, CamelException *ex)
+int
+camel_stream_close (CamelStream *stream)
{
- g_return_if_fail (CAMEL_IS_STREAM (stream));
+ g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
- CS_CLASS (stream)->flush (stream, ex);
+ return CS_CLASS (stream)->close (stream);
}
@@ -166,18 +190,19 @@ camel_stream_eos (CamelStream *stream)
/**
* camel_stream_reset: reset a stream
* @stream: the stream object
- * @ex: a CamelException
*
* Reset a stream. That is, put it in a state where it can be read
* from the beginning again. Not all streams in Camel are seekable,
* but they must all be resettable.
+ *
+ * Return value: -1 on error.
**/
-void
-camel_stream_reset (CamelStream *stream, CamelException *ex)
+int
+camel_stream_reset (CamelStream *stream)
{
- g_return_if_fail (CAMEL_IS_STREAM (stream));
+ g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
- CS_CLASS (stream)->reset (stream, ex);
+ return CS_CLASS (stream)->reset (stream);
}
/***************** Utility functions ********************/
@@ -186,33 +211,28 @@ camel_stream_reset (CamelStream *stream, CamelException *ex)
* camel_stream_write_string:
* @stream: a stream object
* @string: a string
- * @ex: a CamelException
*
* Writes the string to the stream.
*
- * Return value: the number of characters output.
+ * Return value: the number of characters output, -1 on error.
**/
int
-camel_stream_write_string (CamelStream *stream, const char *string,
- CamelException *ex)
+camel_stream_write_string (CamelStream *stream, const char *string)
{
- return camel_stream_write (stream, string, strlen (string), ex);
+ return camel_stream_write (stream, string, strlen (string));
}
/**
* camel_stream_printf:
* @stream: a stream object
- * @ex: a CamelException
* @fmt: a printf-style format string
*
- * This printfs the given data to @stream. If an error occurs, @ex
- * will be set.
+ * This printfs the given data to @stream.
*
- * Return value: the number of characters output.
+ * Return value: the number of characters output, -1 on error.
**/
int
-camel_stream_printf (CamelStream *stream, CamelException *ex,
- const char *fmt, ... )
+camel_stream_printf (CamelStream *stream, const char *fmt, ... )
{
va_list args;
char *string;
@@ -227,7 +247,7 @@ camel_stream_printf (CamelStream *stream, CamelException *ex,
if (!string)
return -1;
- ret = camel_stream_write (stream, string, strlen (string), ex);
+ ret = camel_stream_write (stream, string, strlen (string));
g_free (string);
return ret;
}
@@ -236,7 +256,6 @@ camel_stream_printf (CamelStream *stream, CamelException *ex,
* camel_stream_write_to_stream:
* @stream: Source CamelStream.
* @output_stream: Destination CamelStream.
- * @ex: a CamelException.
*
* Write all of a stream (until eos) into another stream, in a blocking
* fashion.
@@ -245,8 +264,7 @@ camel_stream_printf (CamelStream *stream, CamelException *ex,
* copied across streams.
**/
int
-camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream,
- CamelException *ex)
+camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream)
{
char tmp_buf[4096];
int total = 0;
@@ -257,15 +275,14 @@ camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream,
g_return_val_if_fail (CAMEL_IS_STREAM (output_stream), -1);
while (!camel_stream_eos (stream)) {
- nb_read = camel_stream_read (stream, tmp_buf,
- sizeof (tmp_buf), ex);
+ nb_read = camel_stream_read (stream, tmp_buf, sizeof (tmp_buf));
if (nb_read < 0)
return -1;
else 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, ex);
+ int len = camel_stream_write (output_stream, tmp_buf + nb_written, nb_read - nb_written);
if (len < 0)
return -1;
nb_written += len;