<refentry id="GMimeStreamBuffer">
<refmeta>
<refentrytitle role="top_of_page" id="GMimeStreamBuffer.top_of_page">GMimeStreamBuffer</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  GMIME Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GMimeStreamBuffer</refname>
<refpurpose>A buffered stream</refpurpose>
</refnamediv>

<refsynopsisdiv id="GMimeStreamBuffer.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>enum                <link linkend="GMimeStreamBufferMode">GMimeStreamBufferMode</link>;
                    <link linkend="GMimeStreamBuffer-struct">GMimeStreamBuffer</link>;
<link linkend="GMimeStream"><returnvalue>GMimeStream</returnvalue></link> *       <link linkend="g-mime-stream-buffer-new">g_mime_stream_buffer_new</link>            (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *source</parameter>,
                                                         <parameter><link linkend="GMimeStreamBufferMode"><type>GMimeStreamBufferMode</type></link> mode</parameter>);
<link linkend="ssize-t"><returnvalue>ssize_t</returnvalue></link>             <link linkend="g-mime-stream-buffer-gets">g_mime_stream_buffer_gets</link>           (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *stream</parameter>,
                                                         <parameter><link linkend="char"><type>char</type></link> *buf</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> max</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="g-mime-stream-buffer-readln">g_mime_stream_buffer_readln</link>         (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *stream</parameter>,
                                                         <parameter><link linkend="GByteArray"><type>GByteArray</type></link> *buffer</parameter>);
</synopsis>
</refsynopsisdiv>
<refsect1 id="GMimeStreamBuffer.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----<link linkend="GMimeStream">GMimeStream</link>
         +----GMimeStreamBuffer
</synopsis>
</refsect1>

<refsect1 id="GMimeStreamBuffer.description" role="desc">
<title role="desc.title">Description</title>
<para>
A <link linkend="GMimeStreamBuffer"><type>GMimeStreamBuffer</type></link> 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).
</para>
</refsect1>
<refsect1 id="GMimeStreamBuffer.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GMimeStreamBufferMode" role="enum">
<title>enum GMimeStreamBufferMode</title>
<indexterm zone="GMimeStreamBufferMode"><primary>GMimeStreamBufferMode</primary></indexterm>
<programlisting>typedef enum {
	GMIME_STREAM_BUFFER_CACHE_READ,
	GMIME_STREAM_BUFFER_BLOCK_READ,
	GMIME_STREAM_BUFFER_BLOCK_WRITE
} GMimeStreamBufferMode;
</programlisting>
<para>
The buffering mode for a <link linkend="GMimeStreamBuffer"><type>GMimeStreamBuffer</type></link> stream.
</para><variablelist role="enum">
<varlistentry id="GMIME-STREAM-BUFFER-CACHE-READ:CAPS" role="constant">
<term><literal>GMIME_STREAM_BUFFER_CACHE_READ</literal></term>
<listitem><simpara>Cache all reads.
</simpara></listitem>
</varlistentry>
<varlistentry id="GMIME-STREAM-BUFFER-BLOCK-READ:CAPS" role="constant">
<term><literal>GMIME_STREAM_BUFFER_BLOCK_READ</literal></term>
<listitem><simpara>Read in 4k blocks.
</simpara></listitem>
</varlistentry>
<varlistentry id="GMIME-STREAM-BUFFER-BLOCK-WRITE:CAPS" role="constant">
<term><literal>GMIME_STREAM_BUFFER_BLOCK_WRITE</literal></term>
<listitem><simpara>Write in 4k blocks.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GMimeStreamBuffer-struct" role="struct">
<title>GMimeStreamBuffer</title>
<indexterm zone="GMimeStreamBuffer-struct"><primary>GMimeStreamBuffer</primary></indexterm>
<programlisting>typedef struct _GMimeStreamBuffer GMimeStreamBuffer;</programlisting>
<para>
A buffered stream wrapper around any <link linkend="GMimeStream"><type>GMimeStream</type></link> object.
</para><variablelist role="struct">
</variablelist></refsect2>
<refsect2 id="g-mime-stream-buffer-new" role="function">
<title>g_mime_stream_buffer_new ()</title>
<indexterm zone="g-mime-stream-buffer-new"><primary>g_mime_stream_buffer_new</primary></indexterm>
<programlisting><link linkend="GMimeStream"><returnvalue>GMimeStream</returnvalue></link> *       g_mime_stream_buffer_new            (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *source</parameter>,
                                                         <parameter><link linkend="GMimeStreamBufferMode"><type>GMimeStreamBufferMode</type></link> mode</parameter>);</programlisting>
<para>
Creates a new GMimeStreamBuffer object.
</para><variablelist role="params">
<varlistentry><term><parameter>source</parameter>&#160;:</term>
<listitem><simpara>source stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mode</parameter>&#160;:</term>
<listitem><simpara>buffering mode
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new buffer stream with source <parameter>source</parameter> and mode <parameter>mode</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-stream-buffer-gets" role="function">
<title>g_mime_stream_buffer_gets ()</title>
<indexterm zone="g-mime-stream-buffer-gets"><primary>g_mime_stream_buffer_gets</primary></indexterm>
<programlisting><link linkend="ssize-t"><returnvalue>ssize_t</returnvalue></link>             g_mime_stream_buffer_gets           (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *stream</parameter>,
                                                         <parameter><link linkend="char"><type>char</type></link> *buf</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> max</parameter>);</programlisting>
<para>
Reads in at most one less than <parameter>max</parameter> characters from <parameter>stream</parameter> and
stores them into the buffer pointed to by <parameter>buf</parameter>. 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.
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara>stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buf</parameter>&#160;:</term>
<listitem><simpara>line buffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>max</parameter>&#160;:</term>
<listitem><simpara>max length of a line
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the number of characters read into <parameter>buf</parameter> on success or <link linkend="1:CAPS"><literal>-1</literal></link>
on fail.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-stream-buffer-readln" role="function">
<title>g_mime_stream_buffer_readln ()</title>
<indexterm zone="g-mime-stream-buffer-readln"><primary>g_mime_stream_buffer_readln</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                g_mime_stream_buffer_readln         (<parameter><link linkend="GMimeStream"><type>GMimeStream</type></link> *stream</parameter>,
                                                         <parameter><link linkend="GByteArray"><type>GByteArray</type></link> *buffer</parameter>);</programlisting>
<para>
Reads a single line into <parameter>buffer</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara>stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buffer</parameter>&#160;:</term>
<listitem><simpara>output buffer
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>
<refsect1 id="GMimeStreamBuffer.see-also">
<title>See Also</title>
<link linkend="GMimeStream"><type>GMimeStream</type></link>
</refsect1>

</refentry>
