CamelStream

## CamelStream CamelStream |

## Synopsis

    struct              CamelStream;
    gssize              camel_stream_read                   (CamelStream *stream,
                                                             gchar *buffer,
                                                             gsize n);
    gssize              camel_stream_write                  (CamelStream *stream,
                                                             const gchar *buffer,
                                                             gsize n);
    gint                camel_stream_flush                  (CamelStream *stream);
    gint                camel_stream_close                  (CamelStream *stream);
    gboolean            camel_stream_eos                    (CamelStream *stream);
    gint                camel_stream_reset                  (CamelStream *stream);
    gssize              camel_stream_write_string           (CamelStream *stream,
                                                             const gchar *string);
    gssize              camel_stream_printf                 (CamelStream *stream,
                                                             const gchar *fmt,
                                                             ...);
    gssize              camel_stream_vprintf                (CamelStream *stream,
                                                             const gchar *fmt,
                                                             va_list ap);
    gssize              camel_stream_write_to_stream        (CamelStream *stream,
                                                             CamelStream *output_stream);

## Description

## Details

### struct CamelStream

    struct CamelStream {
    	CamelObject parent_object;

    	gboolean eos;
    };

### camel_stream_read ()

    gssize              camel_stream_read                   (CamelStream *stream,
                                                             gchar *buffer,
                                                             gsize n);

Attempts to read up to `len` bytes from `stream` into `buf`.

`stream` : | a CamelStream object.
`buffer` : | output buffer
`n` : | max number of bytes to read.
Returns : | the number of bytes actually read, or `-1` on error and set errno.

### camel_stream_write ()

    gssize              camel_stream_write                  (CamelStream *stream,
                                                             const gchar *buffer,
                                                             gsize n);

Attempts to write up to `n` bytes of `buffer` into `stream`.

`stream` : | a CamelStream object
`buffer` : | buffer to write.
`n` : | number of bytes to write
Returns : | the number of bytes written to the stream, or `-1` on error along with setting errno.

### camel_stream_flush ()

    gint                camel_stream_flush                  (CamelStream *stream);

Flushes any buffered data to the stream's backing store. Only meaningful for writable streams.

`stream` : | a CamelStream object
Returns : | `0` on success or `-1` on fail along with setting errno.

### camel_stream_close ()

    gint                camel_stream_close                  (CamelStream *stream);

Closes the stream.

`stream` : | a CamelStream object
Returns : | `0` on success or `-1` on error.

### camel_stream_eos ()

    gboolean            camel_stream_eos                    (CamelStream *stream);

Tests if there are bytes left to read on the `stream` object.

`stream` : | a CamelStream object
Returns : | `TRUE` on EOS or `FALSE` otherwise.

### camel_stream_reset ()

    gint                camel_stream_reset                  (CamelStream *stream);

Resets the 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.

`stream` : | a CamelStream object
Returns : | `0` on success or `-1` on error along with setting errno.

### camel_stream_write_string ()

    gssize              camel_stream_write_string           (CamelStream *stream,
                                                             const gchar *string);

Writes the string to the stream.

`stream` : | a CamelStream object
`string` : | a string
Returns : | the number of characters written or `-1` on error.

### camel_stream_printf ()

    gssize              camel_stream_printf                 (CamelStream *stream,
                                                             const gchar *fmt,
                                                             ...);

Write formatted output to a stream.

`stream` : | a CamelStream object
`fmt` : | a printf-style format string
`...` : |
Returns : | the number of characters written or `-1` on error.

### camel_stream_vprintf ()

    gssize              camel_stream_vprintf                (CamelStream *stream,
                                                             const gchar *fmt,
                                                             va_list ap);

`stream` : |
`fmt` : |
`ap` : |
Returns : |

### camel_stream_write_to_stream ()

    gssize              camel_stream_write_to_stream        (CamelStream *stream,
                                                             CamelStream *output_stream);

Write all of a stream (until eos) into another stream, in a blocking fashion.

`stream` : | source CamelStream object
`output_stream` : | destination CamelStream object
Returns : | `-1` on error, or the number of bytes succesfully copied across streams.