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

<refnamediv>
<refname>CamelMimeParser</refname>
<refpurpose></refpurpose>
</refnamediv>

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

<synopsis>
struct              <link linkend="CamelMimeParser">CamelMimeParser</link>;
enum                <link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link>;
<link linkend="CamelMimeParser">CamelMimeParser</link> *   <link linkend="camel-mime-parser-new">camel_mime_parser_new</link>               (void);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-errno">camel_mime_parser_errno</link>             (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-init-with-fd">camel_mime_parser_init_with_fd</link>      (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="int">int</link> fd);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-init-with-stream">camel_mime_parser_init_with_stream</link>  (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="CamelStream">CamelStream</link> *stream);
<link linkend="CamelStream">CamelStream</link> *       <link linkend="camel-mime-parser-stream">camel_mime_parser_stream</link>            (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-fd">camel_mime_parser_fd</link>                (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-scan-from">camel_mime_parser_scan_from</link>         (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="gboolean">gboolean</link> scan_from);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-scan-pre-from">camel_mime_parser_scan_pre_from</link>     (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="gboolean">gboolean</link> scan_pre_from);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-set-header-regex">camel_mime_parser_set_header_regex</link>  (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="char">char</link> *matchstr);
<link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link>  <link linkend="camel-mime-parser-step">camel_mime_parser_step</link>       (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="char">char</link> **databuffer,
                                                         <link linkend="size-t">size_t</link> *datalength);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-unstep">camel_mime_parser_unstep</link>            (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-drop-step">camel_mime_parser_drop_step</link>         (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link>  <link linkend="camel-mime-parser-state">camel_mime_parser_state</link>      (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-push-state">camel_mime_parser_push_state</link>        (<link linkend="CamelMimeParser">CamelMimeParser</link> *mp,
                                                         <link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link> newstate,
                                                         const <link linkend="char">char</link> *boundary);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-read">camel_mime_parser_read</link>              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         const <link linkend="char">char</link> **databuffer,
                                                         <link linkend="int">int</link> len);
<link linkend="CamelContentType">CamelContentType</link> *  <link linkend="camel-mime-parser-content-type">camel_mime_parser_content_type</link>      (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
const <link linkend="char">char</link> *        <link linkend="camel-mime-parser-header">camel_mime_parser_header</link>            (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="int">int</link> *offset);
struct <link linkend="camel-header-raw">_camel_header_raw</link> * <link linkend="camel-mime-parser-headers-raw">camel_mime_parser_headers_raw</link>
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);
const <link linkend="char">char</link> *        <link linkend="camel-mime-parser-preface">camel_mime_parser_preface</link>           (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);
const <link linkend="char">char</link> *        <link linkend="camel-mime-parser-postface">camel_mime_parser_postface</link>          (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);
const <link linkend="char">char</link> *        <link linkend="camel-mime-parser-from-line">camel_mime_parser_from_line</link>         (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);
<link linkend="int">int</link>                 <link linkend="camel-mime-parser-filter-add">camel_mime_parser_filter_add</link>        (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="CamelMimeFilter">CamelMimeFilter</link> *mf);
<link linkend="void">void</link>                <link linkend="camel-mime-parser-filter-remove">camel_mime_parser_filter_remove</link>     (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="int">int</link> id);
<link linkend="off-t">off_t</link>               <link linkend="camel-mime-parser-tell">camel_mime_parser_tell</link>              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="off-t">off_t</link>               <link linkend="camel-mime-parser-seek">camel_mime_parser_seek</link>              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="off-t">off_t</link> offset,
                                                         <link linkend="int">int</link> whence);
<link linkend="off-t">off_t</link>               <link linkend="camel-mime-parser-tell-start-headers">camel_mime_parser_tell_start_headers</link>
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="off-t">off_t</link>               <link linkend="camel-mime-parser-tell-start-from">camel_mime_parser_tell_start_from</link>   (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
<link linkend="off-t">off_t</link>               <link linkend="camel-mime-parser-tell-start-boundary">camel_mime_parser_tell_start_boundary</link>
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);
</synopsis>
</refsynopsisdiv>









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

<refsect1 id="camel-CamelMimeParser.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="CamelMimeParser" role="struct">
<title>struct CamelMimeParser</title>
<indexterm zone="CamelMimeParser"><primary sortas="CamelMimeParser">CamelMimeParser</primary></indexterm><programlisting>struct CamelMimeParser {
	CamelObject parent;

	struct _CamelMimeParserPrivate *priv;
};
</programlisting>
<para>
</para></refsect2>
<refsect2 id="camel-mime-parser-state-t" role="enum">
<title>enum camel_mime_parser_state_t</title>
<indexterm zone="camel-mime-parser-state-t"><primary sortas="camel_mime_parser_state_t">camel_mime_parser_state_t</primary></indexterm><programlisting>typedef enum _camel_mime_parser_state_t {
	CAMEL_MIME_PARSER_STATE_INITIAL,
	CAMEL_MIME_PARSER_STATE_PRE_FROM,       /* data before a 'From' line */
	CAMEL_MIME_PARSER_STATE_FROM,           /* got 'From' line */
	CAMEL_MIME_PARSER_STATE_HEADER,         /* toplevel header */
	CAMEL_MIME_PARSER_STATE_BODY,           /* scanning body of message */
	CAMEL_MIME_PARSER_STATE_MULTIPART,      /* got multipart header */
	CAMEL_MIME_PARSER_STATE_MESSAGE,        /* rfc822 message */
	
	CAMEL_MIME_PARSER_STATE_PART,           /* part of a multipart */
	
	CAMEL_MIME_PARSER_STATE_END = 8,        /* bit mask for 'end' flags */
	
	CAMEL_MIME_PARSER_STATE_EOF = 8,        /* end of file */
	CAMEL_MIME_PARSER_STATE_PRE_FROM_END,   /* pre from end */
	CAMEL_MIME_PARSER_STATE_FROM_END,       /* end of whole from bracket */
	CAMEL_MIME_PARSER_STATE_HEADER_END,     /* dummy value */
	CAMEL_MIME_PARSER_STATE_BODY_END,       /* end of message */
	CAMEL_MIME_PARSER_STATE_MULTIPART_END,  /* end of multipart  */
	CAMEL_MIME_PARSER_STATE_MESSAGE_END     /* end of message */
} camel_mime_parser_state_t;
</programlisting>
<para>
</para></refsect2>
<refsect2 id="camel-mime-parser-new" role="function">
<title>camel_mime_parser_new ()</title>
<indexterm zone="camel-mime-parser-new"><primary sortas="camel_mime_parser_new">camel_mime_parser_new</primary></indexterm><programlisting><link linkend="CamelMimeParser">CamelMimeParser</link> *   camel_mime_parser_new               (void);</programlisting>
<para>
Create a new CamelMimeParser object.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A new CamelMimeParser widget.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-errno" role="function">
<title>camel_mime_parser_errno ()</title>
<indexterm zone="camel-mime-parser-errno"><primary sortas="camel_mime_parser_errno">camel_mime_parser_errno</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_errno             (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-init-with-fd" role="function">
<title>camel_mime_parser_init_with_fd ()</title>
<indexterm zone="camel-mime-parser-init-with-fd"><primary sortas="camel_mime_parser_init_with_fd">camel_mime_parser_init_with_fd</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_init_with_fd      (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="int">int</link> fd);</programlisting>
<para>
Initialise the scanner with an fd.  The scanner's offsets
will be relative to the current file position of the file
descriptor.  As a result, seekable descritors should
be seeked using the parser seek functions.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fd</parameter>&#160;:</term>
<listitem><simpara> A valid file descriptor.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> Returns -1 on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-init-with-stream" role="function">
<title>camel_mime_parser_init_with_stream ()</title>
<indexterm zone="camel-mime-parser-init-with-stream"><primary sortas="camel_mime_parser_init_with_stream">camel_mime_parser_init_with_stream</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_init_with_stream  (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="CamelStream">CamelStream</link> *stream);</programlisting>
<para>
Initialise the scanner with a source stream.  The scanner's
offsets will be relative to the current file position of
the stream.  As a result, seekable streams should only
be seeked using the parser seek function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>stream</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> -1 on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-stream" role="function">
<title>camel_mime_parser_stream ()</title>
<indexterm zone="camel-mime-parser-stream"><primary sortas="camel_mime_parser_stream">camel_mime_parser_stream</primary></indexterm><programlisting><link linkend="CamelStream">CamelStream</link> *       camel_mime_parser_stream            (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Get the stream, if any, the parser has been initialised
with.  May be used to setup sub-streams, but should not
be read from directly (without saving and restoring
the seek position in between).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The stream from <link linkend="init-with-stream"><function>_init_with_stream()</function></link>, or NULL
if the parser is reading from a file descriptor or is
uninitialised.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-fd" role="function">
<title>camel_mime_parser_fd ()</title>
<indexterm zone="camel-mime-parser-fd"><primary sortas="camel_mime_parser_fd">camel_mime_parser_fd</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_fd                (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Return the file descriptor, if any, the parser has been
initialised with.
</para>
<para>
Should not be read from unless the parser it to terminate,
or the seek offset can be reset before the next parse
step.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The file descriptor or -1 if the parser
is reading from a stream or has not been initialised.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-scan-from" role="function">
<title>camel_mime_parser_scan_from ()</title>
<indexterm zone="camel-mime-parser-scan-from"><primary sortas="camel_mime_parser_scan_from">camel_mime_parser_scan_from</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_scan_from         (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="gboolean">gboolean</link> scan_from);</programlisting>
<para>
Tell the scanner if it should scan "^From " lines or not.
</para>
<para>
If the scanner is scanning from lines, two additional
states CAMEL_MIME_PARSER_STATE_FROM and CAMEL_MIME_PARSER_STATE_FROM_END will be returned
to the caller during parsing.
</para>
<para>
This may also be preceeded by an optional
CAMEL_MIME_PARSER_STATE_PRE_FROM state which contains the scanned data
found before the From line is encountered.  See also
<link linkend="scan-pre-from"><function>scan_pre_from()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scan_from</parameter>&#160;:</term>
<listitem><simpara> <link linkend="TRUE--CAPS"><type>TRUE</type></link> if the scanner should scan From lines.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-scan-pre-from" role="function">
<title>camel_mime_parser_scan_pre_from ()</title>
<indexterm zone="camel-mime-parser-scan-pre-from"><primary sortas="camel_mime_parser_scan_pre_from">camel_mime_parser_scan_pre_from</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_scan_pre_from     (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="gboolean">gboolean</link> scan_pre_from);</programlisting>
<para>
Tell the scanner whether we want to know abou the pre-from
data during a scan.  If we do, then we may get an additional
state CAMEL_MIME_PARSER_STATE_PRE_FROM which returns the specified data.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scan_pre_from</parameter>&#160;:</term>
<listitem><simpara> <link linkend="TRUE--CAPS"><type>TRUE</type></link> if we want to get pre-from data.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-set-header-regex" role="function">
<title>camel_mime_parser_set_header_regex ()</title>
<indexterm zone="camel-mime-parser-set-header-regex"><primary sortas="camel_mime_parser_set_header_regex">camel_mime_parser_set_header_regex</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_set_header_regex  (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="char">char</link> *matchstr);</programlisting>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>matchstr</parameter>&#160;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-step" role="function">
<title>camel_mime_parser_step ()</title>
<indexterm zone="camel-mime-parser-step"><primary sortas="camel_mime_parser_step">camel_mime_parser_step</primary></indexterm><programlisting><link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link>  camel_mime_parser_step       (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="char">char</link> **databuffer,
                                                         <link linkend="size-t">size_t</link> *datalength);</programlisting>
<para>
Parse the next part of the MIME message.  If <link linkend="unstep"><function>_unstep()</function></link>
has been called, then continue to return the same state
for that many calls.
</para>
<para>
If the step is CAMEL_MIME_PARSER_STATE_BODY then the databuffer and datalength
pointers will be setup to point to the internal data buffer
of the scanner and may be processed as required.  Any
filters will have already been applied to this data.
</para>
<para>
Refer to the state diagram elsewhere for a full listing of
the states an application is gauranteed to get from the
scanner.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>databuffer</parameter>&#160;:</term>
<listitem><simpara> Pointer to accept a pointer to the data
associated with this step (if any).  May be <link linkend="NULL--CAPS"><type>NULL</type></link>,
in which case datalength is also ingored.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>datalength</parameter>&#160;:</term>
<listitem><simpara> Pointer to accept a pointer to the data
length associated with this step (if any).
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The current new state of the parser
is returned.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-unstep" role="function">
<title>camel_mime_parser_unstep ()</title>
<indexterm zone="camel-mime-parser-unstep"><primary sortas="camel_mime_parser_unstep">camel_mime_parser_unstep</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_unstep            (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Cause the last step operation to repeat itself.  If this is 
called repeated times, then the same step will be repeated
that many times.
</para>
<para>
Note that it is not possible to scan back using this function,
only to have a way of peeking the next state.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-drop-step" role="function">
<title>camel_mime_parser_drop_step ()</title>
<indexterm zone="camel-mime-parser-drop-step"><primary sortas="camel_mime_parser_drop_step">camel_mime_parser_drop_step</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_drop_step         (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Drop the last step call.  This should only be used
in conjunction with seeking of the stream as the
stream may be in an undefined state relative to the
state of the parser.
</para>
<para>
Use this call with care.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-state" role="function">
<title>camel_mime_parser_state ()</title>
<indexterm zone="camel-mime-parser-state"><primary sortas="camel_mime_parser_state">camel_mime_parser_state</primary></indexterm><programlisting><link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link>  camel_mime_parser_state      (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Get the current parser state.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The current parser state.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-push-state" role="function">
<title>camel_mime_parser_push_state ()</title>
<indexterm zone="camel-mime-parser-push-state"><primary sortas="camel_mime_parser_push_state">camel_mime_parser_push_state</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_push_state        (<link linkend="CamelMimeParser">CamelMimeParser</link> *mp,
                                                         <link linkend="camel-mime-parser-state-t">camel_mime_parser_state_t</link> newstate,
                                                         const <link linkend="char">char</link> *boundary);</programlisting>
<para>
Pre-load a new parser state.  Used to post-parse multipart content
without headers.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>mp</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>newstate</parameter>&#160;:</term>
<listitem><simpara> New state
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>boundary</parameter>&#160;:</term>
<listitem><simpara> Boundary marker for state.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-read" role="function">
<title>camel_mime_parser_read ()</title>
<indexterm zone="camel-mime-parser-read"><primary sortas="camel_mime_parser_read">camel_mime_parser_read</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_read              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         const <link linkend="char">char</link> **databuffer,
                                                         <link linkend="int">int</link> len);</programlisting>
<para>
Read at most <parameter>len</parameter> bytes from the internal mime parser buffer.
</para>
<para>
Returns the address of the internal buffer in <parameter>databuffer</parameter>,
and the length of useful data.
</para>
<para>
<parameter>len</parameter> may be specified as INT_MAX, in which case you will
get the full remainder of the buffer at each call.
</para>
<para>
Note that no parsing of the data read through this function
occurs, so no state changes occur, but the seek position
is updated appropriately.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>databuffer</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The number of bytes available, or -1 on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-content-type" role="function">
<title>camel_mime_parser_content_type ()</title>
<indexterm zone="camel-mime-parser-content-type"><primary sortas="camel_mime_parser_content_type">camel_mime_parser_content_type</primary></indexterm><programlisting><link linkend="CamelContentType">CamelContentType</link> *  camel_mime_parser_content_type      (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Get the content type defined in the current part.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A content_type structure, or NULL if there
is no content-type defined for this part of state of the
parser.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-header" role="function">
<title>camel_mime_parser_header ()</title>
<indexterm zone="camel-mime-parser-header"><primary sortas="camel_mime_parser_header">camel_mime_parser_header</primary></indexterm><programlisting>const <link linkend="char">char</link> *        camel_mime_parser_header            (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="int">int</link> *offset);</programlisting>
<para>
Lookup a header by name.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> Name of header.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset</parameter>&#160;:</term>
<listitem><simpara> Pointer that can receive the offset of the header in
the stream from the start of parsing.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The header value, or NULL if the header is not
defined.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-headers-raw" role="function">
<title>camel_mime_parser_headers_raw ()</title>
<indexterm zone="camel-mime-parser-headers-raw"><primary sortas="camel_mime_parser_headers_raw">camel_mime_parser_headers_raw</primary></indexterm><programlisting>struct <link linkend="camel-header-raw">_camel_header_raw</link> * camel_mime_parser_headers_raw
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);</programlisting>
<para>
Get the list of the raw headers which are defined for the
current state of the parser.  These headers are valid
until the next call to <link linkend="parser-step"><function>parser_step()</function></link>, or <link linkend="parser-drop-step"><function>parser_drop_step()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The raw headers, or NULL if there are no headers
defined for the current part or state.  These are READ ONLY.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-preface" role="function">
<title>camel_mime_parser_preface ()</title>
<indexterm zone="camel-mime-parser-preface"><primary sortas="camel_mime_parser_preface">camel_mime_parser_preface</primary></indexterm><programlisting>const <link linkend="char">char</link> *        camel_mime_parser_preface           (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);</programlisting>
<para>
Retrieve the preface text for the current multipart.
Can only be used when the state is CAMEL_MIME_PARSER_STATE_MULTIPART_END.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The preface text, or NULL if there wasn't any.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-postface" role="function">
<title>camel_mime_parser_postface ()</title>
<indexterm zone="camel-mime-parser-postface"><primary sortas="camel_mime_parser_postface">camel_mime_parser_postface</primary></indexterm><programlisting>const <link linkend="char">char</link> *        camel_mime_parser_postface          (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);</programlisting>
<para>
Retrieve the postface text for the current multipart.
Only returns valid data when the current state if
CAMEL_MIME_PARSER_STATE_MULTIPART_END.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The postface text, or NULL if there wasn't any.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-from-line" role="function">
<title>camel_mime_parser_from_line ()</title>
<indexterm zone="camel-mime-parser-from-line"><primary sortas="camel_mime_parser_from_line">camel_mime_parser_from_line</primary></indexterm><programlisting>const <link linkend="char">char</link> *        camel_mime_parser_from_line         (<link linkend="CamelMimeParser">CamelMimeParser</link> *m);</programlisting>
<para>
Get the last scanned "From " line, from a recently scanned from.
This should only be called in the CAMEL_MIME_PARSER_STATE_FROM state.  The
from line will include the closing \n found (if there was one).
</para>
<para>
The return value will remain valid while in the CAMEL_MIME_PARSER_STATE_FROM
state, or any deeper state.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The From line, or NULL if called out of context.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-filter-add" role="function">
<title>camel_mime_parser_filter_add ()</title>
<indexterm zone="camel-mime-parser-filter-add"><primary sortas="camel_mime_parser_filter_add">camel_mime_parser_filter_add</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_mime_parser_filter_add        (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="CamelMimeFilter">CamelMimeFilter</link> *mf);</programlisting>
<para>
Add a filter that will be applied to any body content before it is passed
to the caller.  Filters may be pipelined to perform multi-pass operations
on the content, and are applied in the order they were added.
</para>
<para>
Note that filters are only applied to the body content of messages, and once
a filter has been set, all content returned by a <link linkend="filter-step"><function>filter_step()</function></link> with a state
of CAMEL_MIME_PARSER_STATE_BODY will have passed through the filter.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mf</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> An id that may be passed to <link linkend="filter-remove"><function>filter_remove()</function></link> to remove
the filter, or -1 if the operation failed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-filter-remove" role="function">
<title>camel_mime_parser_filter_remove ()</title>
<indexterm zone="camel-mime-parser-filter-remove"><primary sortas="camel_mime_parser_filter_remove">camel_mime_parser_filter_remove</primary></indexterm><programlisting><link linkend="void">void</link>                camel_mime_parser_filter_remove     (<link linkend="CamelMimeParser">CamelMimeParser</link> *m,
                                                         <link linkend="int">int</link> id);</programlisting>
<para>
Remove a processing filter from the pipeline.  There is no
restriction on the order the filters can be removed.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>m</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>id</parameter>&#160;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-tell" role="function">
<title>camel_mime_parser_tell ()</title>
<indexterm zone="camel-mime-parser-tell"><primary sortas="camel_mime_parser_tell">camel_mime_parser_tell</primary></indexterm><programlisting><link linkend="off-t">off_t</link>               camel_mime_parser_tell              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Return the current scanning offset.  The meaning of this
value will depend on the current state of the parser.
</para>
<para>
An incomplete listing of the states:
</para>
<para>
CAMEL_MIME_PARSER_STATE_INITIAL, The start of the current message.
CAMEL_MIME_PARSER_STATE_HEADER, CAMEL_MIME_PARSER_STATE_MESSAGE, CAMEL_MIME_PARSER_STATE_MULTIPART, the character
position immediately after the end of the header.
CAMEL_MIME_PARSER_STATE_BODY, Position within the message of the start
of the current data block.
CAMEL_MIME_PARSER_STATE_*_END, The position of the character starting
the next section of the scan (the last position + 1 of
the respective current state).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> See above.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-seek" role="function">
<title>camel_mime_parser_seek ()</title>
<indexterm zone="camel-mime-parser-seek"><primary sortas="camel_mime_parser_seek">camel_mime_parser_seek</primary></indexterm><programlisting><link linkend="off-t">off_t</link>               camel_mime_parser_seek              (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser,
                                                         <link linkend="off-t">off_t</link> offset,
                                                         <link linkend="int">int</link> whence);</programlisting>
<para>
Reset the source position to a known value.
</para>
<para>
Note that if the source stream/descriptor was not
positioned at 0 to begin with, and an absolute seek
is specified (whence != SEEK_CUR), then the seek
position may not match the desired seek position.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset</parameter>&#160;:</term>
<listitem><simpara> Number of bytes to offset the seek by.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>whence</parameter>&#160;:</term>
<listitem><simpara> SEEK_SET, SEEK_CUR, SEEK_END
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The new seek offset, or -1 on
an error (for example, trying to seek on a non-seekable
stream or file descriptor).
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-tell-start-headers" role="function">
<title>camel_mime_parser_tell_start_headers ()</title>
<indexterm zone="camel-mime-parser-tell-start-headers"><primary sortas="camel_mime_parser_tell_start_headers">camel_mime_parser_tell_start_headers</primary></indexterm><programlisting><link linkend="off-t">off_t</link>               camel_mime_parser_tell_start_headers
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
Find out the position within the file of where the
headers started, this is cached by the parser
at the time.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The header start position, or -1 if
no headers were scanned in the current state.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-tell-start-from" role="function">
<title>camel_mime_parser_tell_start_from ()</title>
<indexterm zone="camel-mime-parser-tell-start-from"><primary sortas="camel_mime_parser_tell_start_from">camel_mime_parser_tell_start_from</primary></indexterm><programlisting><link linkend="off-t">off_t</link>               camel_mime_parser_tell_start_from   (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
If the parser is scanning From lines, then this returns
the position of the start of the From line.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The start of the from line, or -1 if there
was no From line, or From lines are not being scanned.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-mime-parser-tell-start-boundary" role="function">
<title>camel_mime_parser_tell_start_boundary ()</title>
<indexterm zone="camel-mime-parser-tell-start-boundary"><primary sortas="camel_mime_parser_tell_start_boundary">camel_mime_parser_tell_start_boundary</primary></indexterm><programlisting><link linkend="off-t">off_t</link>               camel_mime_parser_tell_start_boundary
                                                        (<link linkend="CamelMimeParser">CamelMimeParser</link> *parser);</programlisting>
<para>
When parsing a multipart, this returns the start of the last
boundary.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parser</parameter>&#160;:</term>
<listitem><simpara> MIME parser object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The start of the boundary, or -1 if there
was no boundary encountered yet.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
