GMimeReceivedClause

GMimeReceivedClause — Received header clauses

Functions

Types and Values

Description

Ports MimeKit's ReceivedClause model. Keywords retain their spelling, while common clause identifiers are recognized ignoring ASCII case. Values are validated without trimming, unfolding or normalization. Failed assignments leave the previous value and comments unchanged.

Comments are independent UTF-8 strings, without parentheses. Like MimeKit's public comment list, they may be empty and may contain control characters or line breaks. This model does not serialize them; a writer must escape and fold comments rather than emitting them verbatim.

Functions

g_mime_received_clause_new ()

GMimeReceivedClause *
g_mime_received_clause_new (const char *keyword,
                            const char *value,
                            GError **error);

Creates a clause with no comments. The keyword must not start with a hyphen. Common keywords are recognized ignoring case; extension keywords use GMIME_RECEIVED_CLAUSE_UNKNOWN. Invalid text reports GMIME_ERROR_PARSE_ERROR.

Parameters

keyword

a nonempty ASCII keyword containing only letters and hyphens

 

value

a nonempty UTF-8 clause value

 

error

return location for a GError.

[nullable]

Returns

a new clause, or NULL on error.

[transfer full][nullable]


g_mime_received_clause_new_with_comment ()

GMimeReceivedClause *
g_mime_received_clause_new_with_comment
                               (const char *keyword,
                                const char *value,
                                const char *comment,
                                GError **error);

Creates a validated clause with one comment, which may be empty.

Parameters

keyword

the clause keyword

 

value

a nonempty UTF-8 clause value

 

comment

a UTF-8 comment without enclosing parentheses

 

error

return location for a GError.

[nullable]

Returns

a new clause, or NULL on error.

[transfer full][nullable]


g_mime_received_clause_get_id ()

GMimeReceivedClauseId
g_mime_received_clause_get_id (GMimeReceivedClause *clause);

Parameters

clause

a GMimeReceivedClause

 

Returns

the immutable clause identifier.


g_mime_received_clause_get_keyword ()

const char *
g_mime_received_clause_get_keyword (GMimeReceivedClause *clause);

Parameters

clause

a GMimeReceivedClause

 

Returns

the immutable keyword with its original spelling.

[transfer none]


g_mime_received_clause_get_value ()

const char *
g_mime_received_clause_get_value (GMimeReceivedClause *clause);

Parameters

clause

a GMimeReceivedClause

 

Returns

the value, borrowed until the next successful assignment.

[transfer none]


g_mime_received_clause_set_value ()

gboolean
g_mime_received_clause_set_value (GMimeReceivedClause *clause,
                                  const char *value,
                                  GError **error);

Validates and copies value without normalization. Invalid text reports GMIME_ERROR_PARSE_ERROR and leaves the clause unchanged.

Parameters

clause

a GMimeReceivedClause

 

value

a nonempty UTF-8 clause value

 

error

return location for a GError.

[nullable]

Returns

TRUE on success, or FALSE on error.


g_mime_received_clause_get_comment_count ()

int
g_mime_received_clause_get_comment_count
                               (GMimeReceivedClause *clause);

Parameters

clause

a GMimeReceivedClause

 

Returns

the number of comments.


g_mime_received_clause_get_comment ()

const char *
g_mime_received_clause_get_comment (GMimeReceivedClause *clause,
                                    int index);

Parameters

clause

a GMimeReceivedClause

 

index

a zero-based comment index

 

Returns

the comment, borrowed until replaced or removed.

[transfer none]


g_mime_received_clause_index_of_comment ()

int
g_mime_received_clause_index_of_comment
                               (GMimeReceivedClause *clause,
                                const char *comment);

Parameters

clause

a GMimeReceivedClause

 

comment

the comment to find

 

Returns

the first exact, case-sensitive matching index, or -1 if absent.


g_mime_received_clause_add_comment ()

void
g_mime_received_clause_add_comment (GMimeReceivedClause *clause,
                                    const char *comment);

Appends an owned copy of comment .

Parameters

clause

a GMimeReceivedClause

 

comment

a UTF-8 comment, which may be empty

 

g_mime_received_clause_insert_comment ()

void
g_mime_received_clause_insert_comment (GMimeReceivedClause *clause,
                                       int index,
                                       const char *comment);

Inserts an owned copy without changing the order of existing comments.

Parameters

clause

a GMimeReceivedClause

 

index

an insertion index from zero through the comment count

 

comment

a UTF-8 comment, which may be empty

 

g_mime_received_clause_set_comment ()

void
g_mime_received_clause_set_comment (GMimeReceivedClause *clause,
                                    int index,
                                    const char *comment);

Replaces one comment with an owned copy. comment may alias any comment or other string stored in clause .

Parameters

clause

a GMimeReceivedClause

 

index

a zero-based comment index

 

comment

a UTF-8 comment, which may be empty

 

g_mime_received_clause_remove_comment ()

gboolean
g_mime_received_clause_remove_comment (GMimeReceivedClause *clause,
                                       const char *comment);

Removes only the first exact, case-sensitive match.

Parameters

clause

a GMimeReceivedClause

 

comment

the comment to remove

 

Returns

TRUE if a comment was removed, or FALSE if absent.


g_mime_received_clause_remove_comment_at ()

void
g_mime_received_clause_remove_comment_at
                               (GMimeReceivedClause *clause,
                                int index);

Removes one comment, preserving the order of the remaining comments.

Parameters

clause

a GMimeReceivedClause

 

index

a zero-based comment index

 

g_mime_received_clause_clear_comments ()

void
g_mime_received_clause_clear_comments (GMimeReceivedClause *clause);

Removes all comments without changing the keyword or value.

Parameters

clause

a GMimeReceivedClause

 

Types and Values

enum GMimeReceivedClauseId

Identifiers for common Received header clauses.

Members

GMIME_RECEIVED_CLAUSE_NONE

comments before the first keyword

 

GMIME_RECEIVED_CLAUSE_FROM

the sending host

 

GMIME_RECEIVED_CLAUSE_BY

the receiving host

 

GMIME_RECEIVED_CLAUSE_VIA

the physical link or protocol

 

GMIME_RECEIVED_CLAUSE_WITH

the mail protocol

 

GMIME_RECEIVED_CLAUSE_ID

the message identifier

 

GMIME_RECEIVED_CLAUSE_FOR

the recipient mailbox

 

GMIME_RECEIVED_CLAUSE_UNKNOWN

an unrecognized keyword

 

GMimeReceivedClause

typedef struct _GMimeReceivedClause GMimeReceivedClause;

A Received header keyword, value and ordered collection of comments.