| Top |
| GMimeParser * | g_mime_parser_new () |
| GMimeParser * | g_mime_parser_new_with_stream () |
| GMimeParser * | g_mime_parser_new_with_stream_and_storage () |
| void | g_mime_parser_init_with_stream () |
| gboolean | g_mime_parser_init_with_stream_and_storage () |
| GMimeFormat | g_mime_parser_get_format () |
| void | g_mime_parser_set_format () |
| GMimeComplianceOptions * | g_mime_parser_get_compliance_options () |
| void | g_mime_parser_set_compliance_options () |
| void | g_mime_parser_set_compliance_logger () |
| gint64 | g_mime_parser_tell () |
| gboolean | g_mime_parser_eos () |
| GMimeHeaderList * | g_mime_parser_construct_headers () |
| GMimeEntity * | g_mime_parser_construct_part () |
| GMimeMessage * | g_mime_parser_construct_message () |
| char * | g_mime_parser_get_mbox_marker () |
| gint64 | g_mime_parser_get_mbox_marker_offset () |
| gint64 | g_mime_parser_get_headers_begin () |
| gint64 | g_mime_parser_get_headers_end () |
A GMimeParser builds headers, MIME entities and messages using a single
buffered GMimeReader. Mbox and MMDF streams support successive messages.
Optional compliance reporting is enabled with
g_mime_parser_set_compliance_logger(), independently of legacy parser
warnings. Diagnostic settings never change how input is parsed.
GMimeParser *
g_mime_parser_new_with_stream (GMimeStream *stream);
Creates a parser at the current position of stream
.
Content is retained on seekable sources and copied into memory for
nonseekable streams. Use g_mime_parser_new_with_stream_and_storage() to
choose a storage mode explicitly.
GMimeParser * g_mime_parser_new_with_stream_and_storage (GMimeStream *stream,GMimeFormat format,GMimeContentStorage storage,GError **error);
Creates a parser at the current position of stream
with explicit format
and content storage. Memory storage copies content; source storage
references leaf content through substreams. Source storage requires
working tell, seek and substream operations. Seekability is checked with
a zero-offset current-position seek before reading. Unsupported seeking
reports an error rather than falling back to memory; substream errors
are reported when parsing content.
The caller owns stream
in both modes. Neither the parser nor returned
models close a stream still owned by the caller. With source storage,
keep the backing input open and unchanged while parsed content is used;
content views retain it after the parser is released or reinitialized.
void g_mime_parser_init_with_stream (GMimeParser *parser,GMimeStream *stream);
Replaces the input at its current position, discarding buffered data, metadata and any previous error. Neither stream is reset or closed. Parser format, persistence, compliance options and the compliance logger are retained.
Do not read, write, seek or reset stream
while parsing. Persistent part
content may be read between operations: its physical source position is
restored before the next operation. Use g_mime_parser_tell() for logical
positions; the underlying stream can be ahead due to buffered input.
Must not be called from a parsing callback.
gboolean g_mime_parser_init_with_stream_and_storage (GMimeParser *parser,GMimeStream *stream,GMimeFormat format,GMimeContentStorage storage,GError **error);
Replaces the input, format and storage, discarding buffered data, metadata and any previous parsing error. Compliance options and the compliance logger are retained. Neither stream is reset or closed. Previously returned models retain their content and are unaffected by stream replacement.
Source storage has the capability and lifetime requirements described
in g_mime_parser_new_with_stream_and_storage(). Validation occurs before
replacing the input: failure leaves the parser's input, buffered data,
metadata, format and storage unchanged.
Use g_mime_parser_tell() for logical positions. Do not manipulate stream
while parsing; source-backed content may be read between operations.
Must not be called from a parsing callback.
parser |
a GMimeParser context |
|
stream |
replacement input at its current position |
|
format |
the input format |
|
storage |
storage for parsed MIME part content |
|
error |
return location for a GError, or |
void g_mime_parser_set_format (GMimeParser *parser,GMimeFormat format);
Changes the input format without discarding buffered input. Must not be called from a parsing callback.
GMimeComplianceOptions *
g_mime_parser_get_compliance_options (GMimeParser *parser);
Gets the parser's mutable compliance settings, including before a stream is assigned. Changes apply to the next construction operation, not to an active operation. The settings survive stream replacement.
the parser's compliance settings, valid until
replaced by g_mime_parser_set_compliance_options() or the parser is released.
void g_mime_parser_set_compliance_options (GMimeParser *parser,GMimeComplianceOptions *options);
Copies options
for subsequent header, entity and message construction.
Assigning the parser's own settings is safe. Changes made from callbacks
apply to the next operation; the active operation retains its snapshot.
Settings survive stream replacement and do not enable reporting unless
a logger is also assigned. They never change parsing policy.
void g_mime_parser_set_compliance_logger (GMimeParser *parser,GMimeComplianceIssueFunc report,gpointer user_data,GDestroyNotify destroy);
Enables structured MIME compliance reporting during header, entity and
message construction, or disables it when report
is NULL. When disabling,
user_data
and destroy
must also be NULL. Without a logger, compliance
validation is skipped; legacy parser warning callbacks are unaffected.
The logger may be configured before assigning input and survives stream replacement. Replacing or disabling it from a parsing callback takes effect at the next operation. The previous data is released once no active operation uses it, or when the parser is released if the logger remains installed. Diagnostic budgets reset for each construction operation/message.
Callbacks receive borrowed issues and may inspect the parser, change its compliance settings or release their parser reference. They must not start another parse, replace input, or manipulate the underlying stream. Concurrent use of a parser is not supported.
parser |
a GMimeParser context |
|
report |
diagnostic callback. |
[nullable][scope notified][closure user_data][destroy destroy] |
user_data |
application data. |
[nullable] |
destroy |
releases |
[nullable] |
gint64
g_mime_parser_tell (GMimeParser *parser);
Gets the logical input position, excluding unread buffered bytes. Nonseekable streams use offset 0 as their initial origin.
GMimeHeaderList * g_mime_parser_construct_headers (GMimeParser *parser,GMimeParserOptions *options,GError **error);
Reads a header block directly at the current logical position, without searching for a mailbox marker or stripping a byte-order mark. Retains message and content headers, original field bytes and offsets. A blank separator is consumed but is not included in the list.
Empty input returns an empty list. Fatal syntax, header limits and I/O errors discard partial results. Errors remain sticky until stream replacement. Options are copied at the start of each operation. Reentrant or concurrent operations are not supported.
parser |
a GMimeParser context |
|
options |
parser options, or |
[nullable] |
error |
return location for a GError, or |
GMimeEntity * g_mime_parser_construct_part (GMimeParser *parser,GMimeParserOptions *options,GError **error);
Constructs a MIME entity directly at the current logical position, without mailbox marker search or byte-order-mark stripping. All input operations share the same reader and buffered bytes.
Fatal syntax, header limits and I/O errors discard partial results and remain sticky until stream replacement. Options are copied per operation. Reentrant or concurrent operations are not supported.
parser |
a GMimeParser context |
|
options |
parser options, or |
[nullable] |
error |
return location for a GError, or |
GMimeMessage * g_mime_parser_construct_message (GMimeParser *parser,GMimeParserOptions *options,GError **error);
Constructs a message through EOF or the next mailbox delimiter. The first message operation on a newly assigned stream strips an optional UTF-8 byte-order mark. Mbox and MMDF inputs search for an opening marker. Persistent content may be read between successive message operations.
Fatal syntax, header limits and I/O errors discard partial results and remain sticky until stream replacement. Options are copied per operation. Reentrant or concurrent operations are not supported.
parser |
a GMimeParser context |
|
options |
parser options, or |
[nullable] |
error |
return location for a GError, or |
char *
g_mime_parser_get_mbox_marker (GMimeParser *parser);
Gets the opening From-line, excluding CRLF, of the last successfully constructed mbox message. The next construction operation clears it.
gint64
g_mime_parser_get_mbox_marker_offset (GMimeParser *parser);