| Reference Manual of the tinymail framework | ||||
|---|---|---|---|---|
TnyStream;
TnyStreamIface;
gssize tny_stream_read (TnyStream *self,
char *buffer,
gsize n);
gssize tny_stream_write (TnyStream *self,
const char *buffer,
gsize n);
gint tny_stream_flush (TnyStream *self);
gint tny_stream_close (TnyStream *self);
gboolean tny_stream_is_eos (TnyStream *self);
gint tny_stream_reset (TnyStream *self);
gssize tny_stream_write_to_stream (TnyStream *self,
TnyStream *output);
TnyStream is implemented by TnyCamelStream, TnyFsStream, TnyMozEmbedStream, TnyCamelMemStream, TnyVfsStream and TnyGtkTextBufferStream.
A stream is an object that can be written to and can be read from in a streaming fashion.
typedef struct {
GTypeInterface parent;
gssize (*read_func) (TnyStream *self, char *buffer, gsize n);
gssize (*write_func) (TnyStream *self, const char *buffer, gsize n);
gint (*flush_func) (TnyStream *self);
gint (*close_func) (TnyStream *self);
gboolean (*is_eos_func) (TnyStream *self);
gint (*reset_func) (TnyStream *self);
gssize (*write_to_stream_func) (TnyStream *self, TnyStream *output);
} TnyStreamIface;
gssize tny_stream_read (TnyStream *self, char *buffer, gsize n);
Read n bytes self and write it into buffer. It's your responsibility
to pass a buffer that is large enough to hold n bytes.
self : |
a TnyStream object |
buffer : |
a buffer that is at least n in size |
n : |
the max amount of bytes to read from self and to write into buffer |
| Returns : | the number of bytes actually read, or -1 on error and set errno. |
gssize tny_stream_write (TnyStream *self, const char *buffer, gsize n);
Write n bytes of buffer into self. It's your responsibility to pass
a buffer that has at least n bytes.
self : |
a TnyStream object |
buffer : |
a buffer that has at least n bytes |
n : |
the amount of bytes to read from buffer and to write to self |
| Returns : | the number of bytes written to the stream, or -1 on error along with setting errno. |
gint tny_stream_flush (TnyStream *self);
Flushes any buffered data to the stream's backing store.
self : |
a TnyStream object |
| Returns : | 0 on success or -1 on fail along with setting errno. |
gint tny_stream_close (TnyStream *self);
Closes the stream
self : |
a TnyStream object |
| Returns : | 0 on success or -1 on fail. |
gboolean tny_stream_is_eos (TnyStream *self);
Tests if there are bytes left to read on self.
self : |
a TnyStream object |
| Returns : | TRUE on EOS or FALSE otherwise. |
gint tny_stream_reset (TnyStream *self);
Resets self. That is, put it in a state where it can be read from
the beginning again.
self : |
a TnyStream object |
| Returns : | 0 on success or -1 on error along with setting errno. |