GMimeFormatOptions

GMimeFormatOptions — Format options

Functions

Types and Values

Description

A GMimeFormatOptions is used by GMime to determine how to serialize various objects and headers.

Functions

g_mime_format_options_new ()

GMimeFormatOptions *
g_mime_format_options_new (void);

Creates a new set of GMimeFormatOptions.

Returns

new options with the default values and one reference.

[transfer full]


g_mime_format_options_ref ()

GMimeFormatOptions *
g_mime_format_options_ref (GMimeFormatOptions *options);

Atomically acquires a reference to options . This shares the same settings; concurrent changes to the settings still require external synchronization.

Parameters

options

a GMimeFormatOptions

 

Returns

options with an additional reference.

[transfer full]


g_mime_format_options_unref ()

void
g_mime_format_options_unref (GMimeFormatOptions *options);

Atomically releases a reference to options . The options and their owned data are destroyed when the last reference is released.

Parameters


g_mime_format_options_clone ()

GMimeFormatOptions *
g_mime_format_options_clone (GMimeFormatOptions *options);

Creates an independent copy of the settings in options , including hidden headers. Unlike g_mime_format_options_ref() or g_boxed_copy(), this does not share settings.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

a newly allocated GMimeFormatOptions.

[transfer full]


g_mime_format_options_get_default ()

GMimeFormatOptions *
g_mime_format_options_get_default (void);

Gets the default format options.

The returned reference belongs to GMime. Use g_mime_format_options_ref() to retain it independently, or g_mime_format_options_clone() for a copy.

Returns

the default format options.

[transfer none]


g_mime_format_options_get_max_line_length ()

guint
g_mime_format_options_get_max_line_length
                               (GMimeFormatOptions *options);

Gets the line-length target for parameter encoding and header folding. The default is 78.

Parameters

options

a GMimeFormatOptions or NULL for the defaults.

[nullable]

Returns

the configured maximum line length.


g_mime_format_options_set_max_line_length ()

void
g_mime_format_options_set_max_line_length
                               (GMimeFormatOptions *options,
                                guint max_line_length);

Sets the line-length target for parameter encoding and header folding, including addresses, general text, References, Received, and Disposition-Notification-Options headers. RFC 2047 parameter encoded-words remain limited to 75 characters. Oversized parameter names, charset/language declarations, or individual characters may require exceeding the target. Disabling parameter folding suppresses hard line breaks, not parameter encoding or continuation selection.

The global defaults cannot be changed with this setter; use g_mime_format_options_new() or g_mime_format_options_clone(). References, Received, and Disposition-Notification-Options tokens are not split; an oversized token or first token may exceed the target. Address display names are folded between words, keeping quoted strings intact. General text folding preserves encoded-word tokens and can split oversized unencoded tokens over multiple lines. RFC 2047 text and phrase generation still uses legacy word sizing.

Parameters

options

a mutable GMimeFormatOptions

 

max_line_length

a line length between 60 and 998, inclusive

 

g_mime_format_options_get_allow_international ()

gboolean
g_mime_format_options_get_allow_international
                               (GMimeFormatOptions *options);

Gets whether or not international encoding is allowed.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

TRUE if international encoding is allowed or FALSE otherwise.


g_mime_format_options_set_allow_international ()

void
g_mime_format_options_set_allow_international
                               (GMimeFormatOptions *options,
                                gboolean allow);

Sets whether UTF-8 address names, domains, source routes, parameter values, and ordinary text headers can be written without RFC 2047, IDN, or RFC 2231 encoding. Parameter values are quoted as needed; controls and encoded-word-like parameter text still require encoding. Ordinary text headers use Unicode-safe folding, counting UTF-16 units rather than UTF-8 bytes. Explicit raw header values are not reformatted. Parsed text, address and content fields are decoded and re-encoded without replacing their stored raw values. Mailing-list command fields preserve URL boundaries and format comments as UTF-8. Parsed trace, identifier, authentication and signature fields remain unchanged.

Parameters

options

a GMimeFormatOptions

 

allow

TRUE if international encoding is allowed

 

g_mime_format_options_get_allow_mixed_charsets ()

gboolean
g_mime_format_options_get_allow_mixed_charsets
                               (GMimeFormatOptions *options);

Gets whether individual RFC 2047 words may use different charsets. The default is FALSE.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

TRUE if each header value is allowed to be encoded with mixed charsets or FALSE otherwise.


g_mime_format_options_set_allow_mixed_charsets ()

void
g_mime_format_options_set_allow_mixed_charsets
                               (GMimeFormatOptions *options,
                                gboolean allow);

Sets whether RFC 2047 words may use US-ASCII or ISO-8859-1 instead of the requested charset. Disabled by default, so encoded words use the requested charset, or UTF-8 when no charset was specified. Lossless UTF-8 fallback remains possible for an unrepresentable word.

When enabled, words needing other characters still use the requested charset, or UTF-8 if none was specified. This option does not change International UTF-8 output or explicitly assigned raw header values.

Parameters

options

a GMimeFormatOptions

 

allow

TRUE if each header value should be allowed to be encoded with mixed charsets

 

g_mime_format_options_get_param_encoding_method ()

GMimeParamEncodingMethod
g_mime_format_options_get_param_encoding_method
                               (GMimeFormatOptions *options);

Gets the parameter encoding method to use for GMimeParam parameters that do not already have an encoding method specified.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

the encoding method that is currently set.


g_mime_format_options_set_param_encoding_method ()

void
g_mime_format_options_set_param_encoding_method
                               (GMimeFormatOptions *options,
                                GMimeParamEncodingMethod method);

Sets the parameter encoding method to use when encoding parameters which do not have an encoding method specified.

Note: GMIME_PARAM_ENCODING_METHOD_DEFAULT is not allowed.

Parameters

options

a GMimeFormatOptions

 

method

a GMimeParamEncodingMethod

 

g_mime_format_options_get_always_quote_param_values ()

gboolean
g_mime_format_options_get_always_quote_param_values
                               (GMimeFormatOptions *options);

Gets whether otherwise unquoted parameter values should be quoted. The default is FALSE.

Parameters

options

a GMimeFormatOptions or NULL for the defaults.

[nullable]

Returns

TRUE if quoting is requested for all parameters.


g_mime_format_options_set_always_quote_param_values ()

void
g_mime_format_options_set_always_quote_param_values
                               (GMimeFormatOptions *options,
                                gboolean always_quote);

Requests quoting for all parameters written using options . FALSE does not suppress required quoting or a parameter's own request. RFC 2231 encoded values are not quoted. The global defaults cannot be changed with this setter; use g_mime_format_options_new() or g_mime_format_options_clone() to obtain mutable options.

Parameters

options

a mutable GMimeFormatOptions

 

always_quote

whether to quote otherwise unquoted parameter values

 

g_mime_format_options_get_newline_format ()

GMimeNewLineFormat
g_mime_format_options_get_newline_format
                               (GMimeFormatOptions *options);

Gets the new-line format to use when writing out messages and headers.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

the new-line format that is currently set.


g_mime_format_options_set_newline_format ()

void
g_mime_format_options_set_newline_format
                               (GMimeFormatOptions *options,
                                GMimeNewLineFormat newline);

Sets the new-line format that should be used when writing headers and messages. Only GMIME_NEWLINE_FORMAT_UNIX and GMIME_NEWLINE_FORMAT_DOS are valid; GMIME_NEWLINE_FORMAT_MIXED describes input, not an output format.

Parameters

options

a GMimeFormatOptions

 

newline

a GMimeNewLineFormat

 

g_mime_format_options_get_ensure_newline ()

gboolean
g_mime_format_options_get_ensure_newline
                               (GMimeFormatOptions *options);

Gets whether message serialization should complete the final newline. The default is FALSE.

Parameters

options

a GMimeFormatOptions or NULL for the defaults.

[nullable]

Returns

TRUE if final newline completion is requested for messages.


g_mime_format_options_set_ensure_newline ()

void
g_mime_format_options_set_ensure_newline
                               (GMimeFormatOptions *options,
                                gboolean ensure);

Parsed messages normally retain an unterminated final body. Set this option to TRUE to request a final newline when writing a message. The selected newline format determines the sequence to append.

This option applies at message boundaries, including embedded messages; it does not force standalone entities or binary content to end with a newline. It does not add a body to a message without one.

The global defaults cannot be changed with this setter; use g_mime_format_options_new() or g_mime_format_options_clone().

Parameters

options

a mutable GMimeFormatOptions

 

ensure

whether messages should end with a newline

 

g_mime_format_options_get_newline ()

const char *
g_mime_format_options_get_newline (GMimeFormatOptions *options);

Gets a string representing the currently set new-line format.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

a new-line character sequence.


g_mime_format_options_create_newline_filter ()

GMimeFilter *
g_mime_format_options_create_newline_filter
                               (GMimeFormatOptions *options,
                                gboolean ensure_newline);

Creates a GMimeFilter suitable for converting line-endings to the currently set new-line format.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

ensure_newline

TRUE if the output must *always* end with a new line

 

Returns

a GMimeFilter to convert to the specified new-line format.

[transfer full]


g_mime_format_options_is_hidden_header ()

gboolean
g_mime_format_options_is_hidden_header
                               (GMimeFormatOptions *options,
                                const char *header);

Gets whether or not the specified header should be hidden.

Parameters

options

a GMimeFormatOptions or NULL.

[nullable]

header

the name of a header

 

Returns

TRUE if the header should be hidden or FALSE otherwise.


g_mime_format_options_add_hidden_header ()

void
g_mime_format_options_add_hidden_header
                               (GMimeFormatOptions *options,
                                const char *header);

Adds the given header to the list of headers that should be hidden.

Parameters

options

a GMimeFormatOptions

 

header

a header name

 

g_mime_format_options_remove_hidden_header ()

void
g_mime_format_options_remove_hidden_header
                               (GMimeFormatOptions *options,
                                const char *header);

Removes the given header from the list of headers that should be hidden.

Parameters

options

a GMimeFormatOptions

 

header

a header name

 

g_mime_format_options_clear_hidden_headers ()

void
g_mime_format_options_clear_hidden_headers
                               (GMimeFormatOptions *options);

Clears the list of headers that should be hidden.

Parameters

options

a GMimeFormatOptions

 

Types and Values

enum GMimeParamEncodingMethod

The MIME specifications specify that the proper method for encoding Content-Type and Content-Disposition parameter values is the method described in

rfc2231. However, it is common for

some older email clients to improperly encode using the method described in

rfc2047 instead.

Members

GMIME_PARAM_ENCODING_METHOD_DEFAULT

Use the default encoding method set on the GMimeFormatOptions.

 

GMIME_PARAM_ENCODING_METHOD_RFC2231

Use the encoding method described in rfc2231.

 

GMIME_PARAM_ENCODING_METHOD_RFC2047

Use the encoding method described in rfc2047.

 

enum GMimeNewLineFormat

There are two commonly used line-endings used by modern Operating Systems. Unix-based systems such as Linux and Mac OS use a single character ('\n' aka LF) to represent the end of line where-as Windows (or DOS) uses a sequence of two characters ("\r\n" aka CRLF). Most text-based network protocols such as SMTP, POP3, and IMAP use the CRLF sequence as well.

Members

GMIME_NEWLINE_FORMAT_UNIX

The Unix New-Line format ("\n").

 

GMIME_NEWLINE_FORMAT_DOS

The DOS New-Line format ("\r\n").

 

GMIME_NEWLINE_FORMAT_MIXED

Both LF and CRLF occur in parsed content. This input hint cannot be selected as an output or encoder format.

 

GMimeFormatOptions

typedef struct _GMimeFormatOptions GMimeFormatOptions;

Reference-counted format options for serializing various GMime objects. Boxed copies share settings; use g_mime_format_options_clone() for an independent copy.