| Top |
GMimeContentType * g_mime_content_type_new (const char *type,const char *subtype);
Creates a Content-Type object with type type
and subtype subtype
.
GMimeContentType * g_mime_content_type_parse (GMimeParserOptions *options,const char *str);
Parses the input string using best-effort recovery, substituting a
default content type on invalid input and retaining partial parameters.
Use g_mime_content_type_parse_full() for all-or-nothing parsing.
options |
a GMimeParserOptions or |
[nullable] |
str |
input string containing a content-type (and params) |
GMimeContentType * g_mime_content_type_parse_full (GMimeParserOptions *options,const char *str,gssize length,GError **error);
Parses the complete input without substituting a default content type
or ignoring malformed parameters. Syntax errors return NULL with
GMIME_ERROR_PARSE_ERROR and a byte offset relative to str
.
Explicitly bounded input need not be NUL-terminated but cannot contain
embedded NUL bytes.
Comments and whitespace are accepted between tokens. The media type is
an ASCII atom excluding '/', and the subtype is an ASCII MIME token
that may also contain '/'. Parameters use the compliance and duplicate
precedence rules of g_mime_param_list_parse_full().
GMimeContentType *
g_mime_content_type_clone (GMimeContentType *content_type);
Copies the media type, subtype, and all parameters, including their charset, language, encoding method, and quoting preference. Parameters are copied independently in their original order, retaining spelling and any duplicate names recovered by legacy parsing.
char *
g_mime_content_type_get_mime_type (GMimeContentType *content_type);
Allocates a string buffer containing the type and subtype defined
by the content_type
.
char *
g_mime_content_type_to_string (GMimeContentType *content_type);
Formats a display string beginning with "Content-Type: ". Parameter
values are always quoted and escaped, without transport encoding,
folding, or an appended newline. This is not a transport-safe header;
use g_mime_content_type_encode() when serializing a MIME message.
char * g_mime_content_type_encode (GMimeContentType *content_type,GMimeFormatOptions *options);
Encodes the Content-Type field value, including leading whitespace and a terminating newline. The field name is not included.
gboolean g_mime_content_type_is_type (GMimeContentType *content_type,const char *type,const char *subtype);
Compares the given type and subtype with that of the given mime type object.
const char *
g_mime_content_type_get_media_type (GMimeContentType *content_type);
Gets the Content-Type's media type.
void g_mime_content_type_set_media_type (GMimeContentType *content_type,const char *type);
Sets the Content-Type's media type.
const char *
g_mime_content_type_get_media_subtype (GMimeContentType *content_type);
Gets the Content-Type's media sub-type.
void g_mime_content_type_set_media_subtype (GMimeContentType *content_type,const char *subtype);
Sets the Content-Type's media subtype.
const char *
g_mime_content_type_get_boundary (GMimeContentType *content_type);
Gets the boundary parameter without generating a value.
void g_mime_content_type_set_boundary (GMimeContentType *content_type,const char *boundary);
Sets the boundary parameter. An empty string remains an explicit empty
value. Unlike g_mime_multipart_set_boundary(), NULL removes the parameter
rather than generating a boundary.
const char *
g_mime_content_type_get_charset (GMimeContentType *content_type);
Gets the charset parameter without resolving or normalizing its name.
void g_mime_content_type_set_charset (GMimeContentType *content_type,const char *charset);
Sets the charset parameter without resolving or normalizing its name. An empty string remains an explicit empty value.
char * g_mime_content_type_get_charset_encoding (GMimeContentType *content_type,GError **error);
Resolves the charset parameter to a supported canonical MIME charset name,
following MimeKit's ContentType.CharsetEncoding property. Missing, empty,
invalid, and unsupported names return NULL without an error. Other converter
failures report G_CONVERT_ERROR rather than masquerading as an unknown
charset. Resolution uses the same aliases as
g_mime_content_type_set_charset_encoding().
This method does not change the parameter, its metadata, or raw headers. The result is independent of later parameter changes.
gboolean g_mime_content_type_set_charset_encoding (GMimeContentType *content_type,const char *charset,GError **error);
Resolves charset
and assigns its canonical MIME name, following MimeKit's
ContentType.CharsetEncoding property. Unlike g_mime_content_type_set_charset(),
this validates the name before changing any parameters or their owning entity's headers.
Unsupported, empty, or non-token names report G_CONVERT_ERROR.
Generic UTF-16/32 names select little-endian encodings. MimeKit's historical
"unicode" alias selects UTF-8. Available encodings and aliases follow the
platform's iconv implementation; custom managed encodings are not supported.
Borrowed parameter values may safely be passed as charset
.
content_type |
||
charset |
a supported MIME charset name, or |
[nullable] |
error |
return location for an error, or |
const char *
g_mime_content_type_get_format (GMimeContentType *content_type);
Gets the format parameter.
void g_mime_content_type_set_format (GMimeContentType *content_type,const char *format);
Sets the format parameter, typically "fixed" or "flowed" for text/plain. Other values and explicit empty strings are preserved.
const char *
g_mime_content_type_get_name (GMimeContentType *content_type);
Gets the name parameter.
void g_mime_content_type_set_name (GMimeContentType *content_type,const char *name);
Sets the name parameter. Empty strings and whitespace are preserved.
GMimeParamList *
g_mime_content_type_get_parameters (GMimeContentType *content_type);
Gets the Content-Type's parameter list.
const char * g_mime_content_type_get_parameter (GMimeContentType *content_type,const char *name);
Gets the parameter value specified by name
if it's available.
void g_mime_content_type_set_parameter (GMimeContentType *content_type,const char *name,const char *value);
Sets a parameter on the Content-Type.
Note: The name
should be in US-ASCII while the value
should be in
UTF-8.