Top | ![]() |
![]() |
![]() |
![]() |
CamelMimeParser * camel_mime_parser_new (void
);
Create a new CamelMimeParser object.
gint camel_mime_parser_init_with_fd (,
CamelMimeParser *m);
gint fd
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.
gint camel_mime_parser_init_with_stream (,
CamelMimeParser *m,
CamelStream *stream);
GError **error
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.
void camel_mime_parser_init_with_input_stream (,
CamelMimeParser *parser);
GInputStream *input_stream
Initialize the scanner with input_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.
Since: 3.12
void camel_mime_parser_init_with_bytes (,
CamelMimeParser *parser);
GBytes *bytes
Convenience function creates a bytes
and hands
it off to camel_mime_parser_init_with_input_stream()
.
Since: 3.12
CamelStream * camel_mime_parser_stream ();
CamelMimeParser *parser
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).
void camel_mime_parser_scan_from (,
CamelMimeParser *parser);
gboolean scan_from
Tell the scanner if it should scan "^From " lines or not.
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.
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
scan_pre_from()
void camel_mime_parser_scan_pre_from (,
CamelMimeParser *parser);
gboolean scan_pre_from
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.
gint camel_mime_parser_set_header_regex (,
CamelMimeParser *parser);
gchar *matchstr
CamelMimeParserState camel_mime_parser_step (,
CamelMimeParser *parser,
gchar **databuffer);
gsize *datalength
Parse the next part of the MIME message. If _unstep()
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.
Refer to the state diagram elsewhere for a full listing of the states an application is gauranteed to get from the scanner.
parser |
MIME parser object |
|
databuffer |
Pointer to accept a pointer to the data
associated with this step (if any). May be |
[inout][array length=datalength][nullable] |
datalength |
Pointer to accept a pointer to the data length associated with this step (if any). |
[inout][nullable] |
void camel_mime_parser_unstep ();
CamelMimeParser *parser
Cause the last step operation to repeat itself. If this is called repeated times, then the same step will be repeated that many times.
Note that it is not possible to scan back using this function, only to have a way of peeking the next state.
void camel_mime_parser_drop_step ();
CamelMimeParser *parser
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.
Use this call with care.
CamelMimeParserState
camel_mime_parser_state (CamelMimeParser *parser
);
Get the current parser state.
void camel_mime_parser_push_state (,
CamelMimeParser *mpCamelMimeParserState newstate
,const
);gchar *boundary
Pre-load a new parser state. Used to post-parse multipart content without headers.
gssize camel_mime_parser_read (,
CamelMimeParser *parserconst
,gchar **databuffer,
gssize len);
GError **error
Read at most len
bytes from the internal mime parser buffer.
Returns the address of the internal buffer in databuffer
,
and the length of useful data.
len
may be specified as G_MAXSSIZE
Note that no parsing of the data read through this function occurs, so no state changes occur, but the seek position is updated appropriately.
CamelContentType * camel_mime_parser_content_type ();
CamelMimeParser *parser
Get the content type defined in the current part.
constgchar * camel_mime_parser_header (,
CamelMimeParser *mconst
,gchar *name);
gint *offset
Lookup a header by name.
CamelNameValueArray *
camel_mime_parser_dup_headers (CamelMimeParser *m
);
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 parser_step()
parser_drop_step()
The headers, or NULL
camel_name_value_array_free()
.
[transfer full]
Since: 3.24
constgchar * camel_mime_parser_preface ();
CamelMimeParser *m
Retrieve the preface text for the current multipart. Can only be used when the state is CAMEL_MIME_PARSER_STATE_MULTIPART_END.
Since: 2.22
constgchar * camel_mime_parser_postface ();
CamelMimeParser *m
Retrieve the postface text for the current multipart. Only returns valid data when the current state if CAMEL_MIME_PARSER_STATE_MULTIPART_END.
Since: 2.22
constgchar * camel_mime_parser_from_line ();
CamelMimeParser *m
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).
The return value will remain valid while in the CAMEL_MIME_PARSER_STATE_FROM state, or any deeper state.
Since: 2.22
gint camel_mime_parser_filter_add (,
CamelMimeParser *m);
CamelMimeFilter *mf
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.
Note that filters are only applied to the body content of messages, and once
a filter has been set, all content returned by a filter_step()
An id that may be passed to filter_remove()
Since: 2.22
void camel_mime_parser_filter_remove (,
CamelMimeParser *m);
gint id
Remove a processing filter from the pipeline. There is no restriction on the order the filters can be removed.
m |
a |
|
id |
id of the filter to remove, as returned from |
Since: 2.22
goffset camel_mime_parser_tell ();
CamelMimeParser *parser
Return the current scanning offset. The meaning of this value will depend on the current state of the parser.
An incomplete listing of the states:
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).
Since: 2.22
goffset camel_mime_parser_seek (,
CamelMimeParser *parser,
goffset offset);
gint whence
Reset the source position to a known value.
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.
parser |
MIME parser object |
|
offset |
Number of bytes to offset the seek by. |
|
whence |
SEEK_SET, SEEK_CUR, SEEK_END |
The new seek offset, or -1 on an error (for example, trying to seek on a non-seekable stream or file descriptor).
Since: 2.22
goffset camel_mime_parser_tell_start_headers ();
CamelMimeParser *parser
Find out the position within the file of where the headers started, this is cached by the parser at the time.
Since: 2.22
goffset camel_mime_parser_tell_start_from ();
CamelMimeParser *parser
If the parser is scanning From lines, then this returns the position of the start of the From line.
The start of the from line, or -1 if there was no From line, or From lines are not being scanned.
Since: 2.22
goffset camel_mime_parser_tell_start_boundary ();
CamelMimeParser *parser
When parsing a multipart, this returns the start of the last boundary.
Since: 2.22