GMimeStreamBuffer

## GMimeStreamBuffer GMimeStreamBuffer — A buffered stream |

## Synopsis

    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);

## Object Hierarchy

      GObject
       +----GMimeStream
             +----GMimeStreamBuffer

## Description

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).

## Details

### enum GMimeStreamBufferMode

    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.

`GMIME_STREAM_BUFFER_CACHE_READ` | Cache all reads.
`GMIME_STREAM_BUFFER_BLOCK_READ` | Read in 4k blocks.
`GMIME_STREAM_BUFFER_BLOCK_WRITE` | Write in 4k blocks.

### GMimeStreamBuffer

    typedef struct _GMimeStreamBuffer GMimeStreamBuffer;

### g_mime_stream_buffer_new ()

    GMimeStream*        g_mime_stream_buffer_new            (GMimeStream *source,
                                                             GMimeStreamBufferMode mode);

Creates a new GMimeStreamBuffer object.

`source` : | source stream
`mode` : | buffering mode
Returns : | a new buffer stream with source `source` and mode `mode`.

### g_mime_stream_buffer_gets ()

    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` : | stream
`buf` : | line buffer
`max` : | max length of a line
Returns : | the number of characters read into `buf` on success and -1 on fail.

### g_mime_stream_buffer_readln ()

    void                g_mime_stream_buffer_readln         (GMimeStream *stream,
                                                             GByteArray *buffer);

Reads a single line into `buffer`.

`stream` : | stream
`buffer` : | output buffer

## See Also

GMimeStream