GMime 2.4 Reference Manual | ||||
---|---|---|---|---|
enum GMimeStreamBufferMode; GMimeStreamBuffer; GMimeStream* g_mime_stream_buffer_new (GMimeStream *source, GMimeStreamBufferMode mode); ssize_t g_mime_stream_buffer_gets (GMimeStream *stream, char *buf, size_t max); void g_mime_stream_buffer_readln (GMimeStream *stream, GByteArray *buffer);
A GMimeStreamBuffer can be used on top of any other type of stream and has 3 modes: block reads, block writes, and cached reads. Block reads are especially useful if you will be making a lot of small reads from a stream that accesses the file system. Block writes are useful for very much the same reason. The final mode, cached reads, can become memory intensive but can be very helpful when inheriting from a stream that does not support seeking (Note: this mode is the least tested so be careful using it).
typedef enum { GMIME_STREAM_BUFFER_CACHE_READ, GMIME_STREAM_BUFFER_BLOCK_READ, GMIME_STREAM_BUFFER_BLOCK_WRITE } GMimeStreamBufferMode;
The buffering mode for a GMimeStreamBuffer stream.
typedef struct _GMimeStreamBuffer GMimeStreamBuffer;
A buffered stream wrapper around any GMimeStream object.
GMimeStream* g_mime_stream_buffer_new (GMimeStream *source, GMimeStreamBufferMode mode);
Creates a new GMimeStreamBuffer object.
|
source stream |
|
buffering mode |
Returns : |
a new buffer stream with source source and mode mode .
|
ssize_t g_mime_stream_buffer_gets (GMimeStream *stream, char *buf, size_t max);
Reads in at most one less than max
characters from stream
and
stores them into the buffer pointed to by buf
. Reading stops after
an EOS or newline ('\n'). If a newline is read, it is stored into
the buffer. A '\0' is stored after the last character in the
buffer.
|
stream |
|
line buffer |
|
max length of a line |
Returns : |
the number of characters read into buf on success or -1
on fail.
|
void g_mime_stream_buffer_readln (GMimeStream *stream, GByteArray *buffer);
Reads a single line into buffer
.
|
stream |
|
output buffer |