## GMimeStreamBuffer GMimeStreamBuffer — A buffered stream |

## Functions

GMimeStream * | g_mime_stream_buffer_new ()
ssize_t | g_mime_stream_buffer_gets ()
void | g_mime_stream_buffer_readln ()

## Types and Values

enum | GMimeStreamBufferMode
struct | GMimeStreamBuffer

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

## Functions

### g_mime_stream_buffer_new ()

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

Creates a new GMimeStreamBuffer object.

#### Parameters

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.

#### Parameters

stream | stream |
buf | line buffer |
max | max length of a line |

#### Returns

the number of characters read into `buf` on success or `-1` on fail.

### g_mime_stream_buffer_readln ()

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

Reads a single line into `buffer` .

#### Parameters

stream | stream |
buffer | output buffer |

## Types and Values

### enum GMimeStreamBufferMode

The buffering mode for a GMimeStreamBuffer stream.

#### Members

GMIME_STREAM_BUFFER_BLOCK_READ | Read in 4k blocks. |
GMIME_STREAM_BUFFER_BLOCK_WRITE | Write in 4k blocks. |

### struct GMimeStreamBuffer

    struct GMimeStreamBuffer;

A buffered stream wrapper around any GMimeStream object.

#### Members

## See Also

GMimeStream