MimeParser
Object Hierarchy:
Description:
[
CCode ( type_id =
"camel_mime_parser_get_type ()" ) ]
public class MimeParser :
Object
Core MIME message parser.
MimeParser is the core mail parsing object in Camel. It parses either a raw RFC 822 message or a Berkeley mbox
file from a stream or a Unix file descriptor. It is a robust, fast, stack-based state machine that handles all failure cases gracefully
— truncated parts, missing multipart boundaries, I/O errors — always producing a valid state sequence.
The parser exposes a simple state machine via step. States follow a well-defined
sequence for each message structure element: every "start" state has a matching "end" state, and you can efficiently skip sections you are
not interested in.
In addition to parsing, the parser can be used to: - Automatically reformat data as it is parsed. - Efficiently skip sections without
reading their content. - Drive MimeFilter instances in a pipelined fashion for
zero-copy decoding.
Because MimeParser does its own I/O buffering, initialising it from a file descriptor (
init_with_fd) is more efficient than from a stream.
Content:
Creation methods:
Methods:
- public virtual void content ()
- public ContentType? content_type ()
Get the content type defined in the current part.
- public void drop_step ()
Drop the last step call.
- public NameValueArray? dup_headers ()
Get the list of the raw headers which are defined for the current
state of the parser.
- public int errno ()
- public int filter_add (MimeFilter mf)
Add a filter that will be applied to any body content before it is
passed to the caller.
- public void filter_remove (int id)
Remove a processing filter from the pipeline.
- public unowned string? from_line ()
Get the last scanned "From " line, from a recently scanned from.
- public unowned string? header (string name, int offset)
Lookup a header by name.
- public void init_with_bytes (Bytes bytes)
- public int init_with_fd (int fd)
Initialise the scanner with an fd.
- public void init_with_input_stream (InputStream input_stream)
Initialize the scanner with input_stream.
- public int init_with_stream (Stream stream) throws Error
Initialise the scanner with a source stream.
- public virtual void message (void* headers)
- public virtual void part ()
- public unowned string? postface ()
Retrieve the postface text for the current multipart.
- public unowned string? preface ()
Retrieve the preface text for the current multipart.
- public void push_state (MimeParserState newstate, string boundary)
Pre-load a new parser state.
- public ssize_t read (out uint8[] databuffer, ssize_t len) throws Error
Read at most len bytes from the internal mime parser
buffer.
- public void scan_from (bool scan_from)
Tell the scanner if it should scan "^From " lines or not.
- public void scan_pre_from (bool scan_pre_from)
Tell the scanner whether we want to know abou the pre-from data during
a scan.
- public int64 seek (int64 offset, int whence)
Reset the source position to a known value.
- public MimeParserState state ()
Get the current parser state.
- public MimeParserState step (ref uint8[] databuffer)
Parse the next part of the MIME message.
- public unowned Stream? stream ()
Get the stream, if any, the parser has been initialised with.
- public int64 tell ()
Return the current scanning offset.
- public int64 tell_start_boundary ()
When parsing a multipart, this returns the start of the last boundary.
- public int64 tell_start_from ()
If the parser is scanning From lines, then this returns the position
of the start of the From line.
- public int64 tell_start_headers ()
Find out the position within the file of where the headers started,
this is cached by the parser at the time.
- public void unstep ()
Cause the last step operation to repeat itself.
Inherited Members:
All known members inherited from class GLib.Object