<refentry id="camel-CamelIMAP4Stream">
<refmeta>
<refentrytitle role="top_of_page" id="camel-CamelIMAP4Stream.top_of_page">CamelIMAP4Stream</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>CAMEL Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>CamelIMAP4Stream</refname>
<refpurpose></refpurpose>
</refnamediv>

<refsynopsisdiv id="camel-CamelIMAP4Stream.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
#define             <link linkend="IMAP4-READ-PRELEN--CAPS">IMAP4_READ_PRELEN</link>
#define             <link linkend="IMAP4-READ-BUFLEN--CAPS">IMAP4_READ_BUFLEN</link>
                    <link linkend="camel-imap4-token-t">camel_imap4_token_t</link>;
                    <link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link>;
<link linkend="CamelStream">CamelStream</link> *       <link linkend="camel-imap4-stream-new">camel_imap4_stream_new</link>              (<link linkend="CamelStream">CamelStream</link> *stream);
<link linkend="int">int</link>                 <link linkend="camel-imap4-stream-next-token">camel_imap4_stream_next_token</link>       (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         <link linkend="camel-imap4-token-t">camel_imap4_token_t</link> *token);
<link linkend="int">int</link>                 <link linkend="camel-imap4-stream-unget-token">camel_imap4_stream_unget_token</link>      (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         <link linkend="camel-imap4-token-t">camel_imap4_token_t</link> *token);
<link linkend="int">int</link>                 <link linkend="camel-imap4-stream-line">camel_imap4_stream_line</link>             (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         unsigned <link linkend="char">char</link> **line,
                                                         <link linkend="size-t">size_t</link> *len);
<link linkend="int">int</link>                 <link linkend="camel-imap4-stream-literal">camel_imap4_stream_literal</link>          (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         unsigned <link linkend="char">char</link> **literal,
                                                         <link linkend="size-t">size_t</link> *len);
</synopsis>
</refsynopsisdiv>









<refsect1 id="camel-CamelIMAP4Stream.description" role="desc">
<title role="desc.title">Description</title>
<para>
</para>
</refsect1>

<refsect1 id="camel-CamelIMAP4Stream.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="IMAP4-READ-PRELEN--CAPS" role="macro">
<title>IMAP4_READ_PRELEN</title>
<indexterm zone="IMAP4-READ-PRELEN--CAPS"><primary sortas="IMAP4_READ_PRELEN">IMAP4_READ_PRELEN</primary></indexterm><programlisting>#define IMAP4_READ_PRELEN   128
</programlisting>
<para>
</para></refsect2>
<refsect2 id="IMAP4-READ-BUFLEN--CAPS" role="macro">
<title>IMAP4_READ_BUFLEN</title>
<indexterm zone="IMAP4-READ-BUFLEN--CAPS"><primary sortas="IMAP4_READ_BUFLEN">IMAP4_READ_BUFLEN</primary></indexterm><programlisting>#define IMAP4_READ_BUFLEN   4096
</programlisting>
<para>
</para></refsect2>
<refsect2 id="camel-imap4-token-t" role="struct">
<title>camel_imap4_token_t</title>
<indexterm zone="camel-imap4-token-t"><primary sortas="camel_imap4_token_t">camel_imap4_token_t</primary></indexterm><programlisting>typedef struct {
	int token;
	union {
		char *atom;
		char *flag;
		char *qstring;
		size_t literal;
		guint32 number;
	} v;
} camel_imap4_token_t;
</programlisting>
<para>
</para></refsect2>
<refsect2 id="CamelIMAP4Stream" role="struct">
<title>CamelIMAP4Stream</title>
<indexterm zone="CamelIMAP4Stream"><primary sortas="CamelIMAP4Stream">CamelIMAP4Stream</primary></indexterm><programlisting>typedef struct {
	CamelStream parent_object;
	
	CamelStream *stream;
	
	guint disconnected:1;  /* disconnected state */
	guint have_unget:1;    /* have an unget token */
	guint mode:1;          /* TOKEN vs LITERAL */
	guint eol:1;           /* end-of-literal */
	
	size_t literal;
	
	/* i/o buffers */
	unsigned char realbuf[IMAP4_READ_PRELEN + IMAP4_READ_BUFLEN + 1];
	unsigned char *inbuf;
	unsigned char *inptr;
	unsigned char *inend;
	
	/* token buffers */
	unsigned char *tokenbuf;
	unsigned char *tokenptr;
	unsigned int tokenleft;
	
	camel_imap4_token_t unget;
} CamelIMAP4Stream;
</programlisting>
<para>
</para></refsect2>
<refsect2 id="camel-imap4-stream-new" role="function">
<title>camel_imap4_stream_new ()</title>
<indexterm zone="camel-imap4-stream-new"><primary sortas="camel_imap4_stream_new">camel_imap4_stream_new</primary></indexterm><programlisting><link linkend="CamelStream">CamelStream</link> *       camel_imap4_stream_new              (<link linkend="CamelStream">CamelStream</link> *stream);</programlisting>
<para>
</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> tcp stream
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new imap4 stream
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap4-stream-next-token" role="function">
<title>camel_imap4_stream_next_token ()</title>
<indexterm zone="camel-imap4-stream-next-token"><primary sortas="camel_imap4_stream_next_token">camel_imap4_stream_next_token</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_imap4_stream_next_token       (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         <link linkend="camel-imap4-token-t">camel_imap4_token_t</link> *token);</programlisting>
<para>
Reads the next token from the imap4 stream and saves it in <parameter>token</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> imap4 stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>token</parameter>&#160;:</term>
<listitem><simpara> imap4 token
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> 0 on success or -1 on fail.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap4-stream-unget-token" role="function">
<title>camel_imap4_stream_unget_token ()</title>
<indexterm zone="camel-imap4-stream-unget-token"><primary sortas="camel_imap4_stream_unget_token">camel_imap4_stream_unget_token</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_imap4_stream_unget_token      (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         <link linkend="camel-imap4-token-t">camel_imap4_token_t</link> *token);</programlisting>
<para>
Ungets an imap4 token (as in <link linkend="ungetc"><function>ungetc()</function></link>).
</para>
<para>
Note: you may *ONLY* unget a single token. Trying to unget another
token will fail.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> imap4 stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>token</parameter>&#160;:</term>
<listitem><simpara> token to 'unget'
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> 0 on success or -1 on fail.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap4-stream-line" role="function">
<title>camel_imap4_stream_line ()</title>
<indexterm zone="camel-imap4-stream-line"><primary sortas="camel_imap4_stream_line">camel_imap4_stream_line</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_imap4_stream_line             (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         unsigned <link linkend="char">char</link> **line,
                                                         <link linkend="size-t">size_t</link> *len);</programlisting>
<para>
Reads a single line from the imap4 stream and points <parameter>line</parameter> at an
internal buffer containing the line read and sets <parameter>len</parameter> to the
length of the line buffer.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> imap4 stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>line</parameter>&#160;:</term>
<listitem><simpara> line pointer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara> line length
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> -1 on error, 0 if the line read is complete, or 1 if the
read is incomplete.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap4-stream-literal" role="function">
<title>camel_imap4_stream_literal ()</title>
<indexterm zone="camel-imap4-stream-literal"><primary sortas="camel_imap4_stream_literal">camel_imap4_stream_literal</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_imap4_stream_literal          (<link linkend="CamelIMAP4Stream">CamelIMAP4Stream</link> *stream,
                                                         unsigned <link linkend="char">char</link> **literal,
                                                         <link linkend="size-t">size_t</link> *len);</programlisting>
<para>
Sets <parameter>literal</parameter> to the beginning of the next chunk of the literal
buffer from the IMAP stream and sets <parameter>len</parameter> to the length of the
<parameter>literal</parameter> buffer.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> IMAP stream
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>literal</parameter>&#160;:</term>
<listitem><simpara> literal pointer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara> literal length
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> &gt;0 if more literal data exists, 0 if the end of the literal
has been reached or -1 on fail.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
