| Top |
A GMimeFormatOptions is used by GMime to determine how to serialize various objects and headers.
GMimeFormatOptions *
g_mime_format_options_new (void);
Creates a new set of GMimeFormatOptions.
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.
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.
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.
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.
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.
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.
options |
a mutable GMimeFormatOptions |
|
max_line_length |
a line length between 60 and 998, inclusive |
gboolean
g_mime_format_options_get_allow_international
(GMimeFormatOptions *options);
Gets whether or not international encoding is allowed.
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.
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.
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.
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.
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.
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.
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.
options |
a mutable GMimeFormatOptions |
|
always_quote |
whether to quote otherwise unquoted parameter values |
GMimeNewLineFormat
g_mime_format_options_get_newline_format
(GMimeFormatOptions *options);
Gets the new-line format to use when writing out messages and headers.
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.
gboolean
g_mime_format_options_get_ensure_newline
(GMimeFormatOptions *options);
Gets whether message serialization should complete the final newline.
The default is FALSE.
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().
const char *
g_mime_format_options_get_newline (GMimeFormatOptions *options);
Gets a string representing the currently set new-line format.
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.
options |
a GMimeFormatOptions or |
[nullable] |
ensure_newline |
|
gboolean g_mime_format_options_is_hidden_header (GMimeFormatOptions *options,const char *header);
Gets whether or not the specified header should be hidden.
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.
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.
void
g_mime_format_options_clear_hidden_headers
(GMimeFormatOptions *options);
Clears the list of headers that should be hidden.
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 forsome older email clients to improperly encode using the method described in
rfc2047 instead.|
Use the default encoding method set on the GMimeFormatOptions. |
||
|
Use the encoding method described in rfc2231. |
||
|
Use the encoding method described in rfc2047. |
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.
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.