| Top |
Parses Received header values following MimeKit's clause recovery rules.
Clauses retain their order and keyword spelling; their parsed values are
not subjected to the stricter public ReceivedClause constructor checks.
Duplicate known clauses, incomplete comments and nonempty invalid dates
fail with GMIME_ERROR_PARSE_ERROR.
Named setters update or remove the first matching clause. Adding a missing named clause sorts the entire collection by clause identifier; updating or removing an existing clause does not sort. Unlike MimeKit's unstable List.Sort(), equal identifiers retain their relative order, so adding a different clause cannot change which duplicate is first. Direct collection operations preserve order and permit duplicate and shared clause instances, but not NULL entries.
GMimeReceived *
g_mime_received_new (void);
Creates an empty value with no clauses or date.
GMimeReceived * g_mime_received_new_with_hosts (const char *from,GInetAddress *from_tcp_info,const char *by,GInetAddress *by_tcp_info,GDateTime *date_time,GError **error);
Creates validated From and By clauses with bracketed IP address comments.
Host strings and address text are copied; the addresses are not retained.
Invalid host values report GMIME_ERROR_PARSE_ERROR.
GInetAddress does not carry an IPv6 scope ID. Scoped address comments can
instead be assigned with g_mime_received_set_from_tcp_info() and
g_mime_received_set_by_tcp_info().
from |
the sending host's domain or address literal |
|
from_tcp_info |
the sending host's IP address |
|
by |
the receiving host's domain or address literal |
|
by_tcp_info |
the receiving host's IP address |
|
date_time |
the date and timezone offset to retain. |
[transfer none] |
error |
return location for a GError. |
[nullable] |
GMimeReceived * g_mime_received_parse (GMimeParserOptions *options,const char *text,gssize length,GError **error);
Parses a header value, not its field name. Empty input, missing clause
values and missing dates are accepted. Parsed clauses bypass constructor
validation, retain keyword spelling and collapse whitespace between value
tokens to one space. Leading comments form a GMIME_RECEIVED_CLAUSE_NONE
clause. Known keywords may occur only once; repeated extensions are allowed.
Raw text uses the parser's fallback charset, without RFC 2047 decoding.
Embedded NUL characters are represented as U+FFFD in returned strings.
Input is bounded by length
and is not retained.
options |
a GMimeParserOptions or |
[nullable] |
text |
the raw Received header value. |
[array length=length][element-type guint8] |
length |
the input byte length, or -1 for a NUL-terminated string |
|
error |
return location for a GError. |
[nullable] |
char * g_mime_received_to_string (GMimeReceived *received,GMimeFormatOptions *options);
Serializes the value without its field name, including leading whitespace and a terminating newline. Folding accounts for the "Received:" field name and counts UTF-16 units like MimeKit. Individual tokens are not split and may exceed the configured line-length target.
Comments are unfolded and backslashes escaped. Clauses retain their order,
keyword spelling and values. Parsed dates retain their unfolded spelling
until date assignment invalidates the cache. Otherwise dates use
g_mime_utils_header_format_date(). No RFC 2047 or IDN encoding is applied.
GMimeReceivedClause * g_mime_received_get_clause (GMimeReceived *received,int index);
void g_mime_received_set_clause (GMimeReceived *received,int index,GMimeReceivedClause *clause);
Retains clause
and releases the old entry without validating or sorting.
Replacing an entry with itself is safe. Duplicate instances are allowed.
void g_mime_received_add_clause (GMimeReceived *received,GMimeReceivedClause *clause);
Retains clause
without validating or sorting. Duplicate instances are allowed.
void g_mime_received_insert_clause (GMimeReceived *received,int index,GMimeReceivedClause *clause);
Retains clause
at index
without validating or sorting.
received |
||
index |
an index from zero through the clause count |
|
clause |
the clause to insert. |
[transfer none] |
int g_mime_received_index_of_clause (GMimeReceived *received,GMimeReceivedClause *clause);
gboolean g_mime_received_contains_clause (GMimeReceived *received,GMimeReceivedClause *clause);
gboolean g_mime_received_remove_clause (GMimeReceived *received,GMimeReceivedClause *clause);
Removes and releases only the first occurrence, preserving remaining order.
void g_mime_received_remove_clause_at (GMimeReceived *received,int index);
Removes and releases the indexed entry without reordering survivors.
void
g_mime_received_clear_clauses (GMimeReceived *received);
Removes and releases every clause without changing the date.
GDateTime *
g_mime_received_get_date_time (GMimeReceived *received);
void g_mime_received_set_date_time (GMimeReceived *received,GDateTime *date_time);
Retains date_time
. Always clears the cached parsed date spelling, even
when assigning the existing date. Does not change clauses.
gboolean g_mime_received_set_from (GMimeReceived *received,const char *value,GError **error);
Updates the first From clause without changing its keyword or comments.
A missing clause is created and the collection sorted by identifier.
Invalid values report GMIME_ERROR_PARSE_ERROR without changing the model.
const char *
g_mime_received_get_from_tcp_info (GMimeReceived *received);
void g_mime_received_set_from_tcp_info (GMimeReceived *received,const char *comment);
Replaces all comments of the first From clause with an unfolded copy.
Tabs become spaces and CR/LF are removed; other whitespace is preserved.
If absent and comment
is non-NULL, creates an empty-valued From clause
and sorts the collection by identifier. NULL does not create a clause.
gboolean g_mime_received_set_by (GMimeReceived *received,const char *value,GError **error);
Updates or removes the first By clause, as g_mime_received_set_from()
does for From. Failed validation leaves the model unchanged.
const char *
g_mime_received_get_by_tcp_info (GMimeReceived *received);
void g_mime_received_set_by_tcp_info (GMimeReceived *received,const char *comment);
Replaces all comments of the first By clause, as
g_mime_received_set_from_tcp_info() does for From.
gboolean g_mime_received_set_via (GMimeReceived *received,const char *value,GError **error);
Updates or removes the first Via clause. New clauses sort the collection by identifier. Values are not trimmed and must pass clause validation. Failed validation leaves the model unchanged.
gboolean g_mime_received_set_with (GMimeReceived *received,const char *value,GError **error);
Updates or removes the first With clause using the same ordering and
validation rules as g_mime_received_set_via().
gboolean g_mime_received_set_id (GMimeReceived *received,const char *value,GError **error);
Updates or removes the first Id clause. New clauses sort the collection. Uses complete lenient message-id validation without normalizing the value. Failed validation leaves the model unchanged.
gboolean g_mime_received_set_for (GMimeReceived *received,const char *value,GError **error);
Updates or removes the first For clause. New clauses sort the collection. Uses the existing mailbox parser without normalizing the stored value. Failed validation leaves the model unchanged.