GMimeContentDisposition

GMimeContentDisposition — Content-Disposition fields

Functions

Types and Values

Description

A GMimeContentDisposition represents the pre-parsed contents of a Content-Disposition header field.

Functions

g_mime_content_disposition_new ()

GMimeContentDisposition *
g_mime_content_disposition_new (void);

Creates a new GMimeContentDisposition object.

Returns

a new GMimeContentDisposition object.


g_mime_content_disposition_parse ()

GMimeContentDisposition *
g_mime_content_disposition_parse (GMimeParserOptions *options,
                                  const char *str);

Parses the input string using best-effort recovery, accepting arbitrary disposition text and retaining partial parameters. Use g_mime_content_disposition_parse_full() for all-or-nothing parsing.

Parameters

options

a GMimeParserOptions or NULL.

[nullable]

str

Content-Disposition field value

 

Returns

a new GMimeContentDisposition object.

[transfer full]


g_mime_content_disposition_parse_full ()

GMimeContentDisposition *
g_mime_content_disposition_parse_full (GMimeParserOptions *options,
                                       const char *str,
                                       gssize length,
                                       GError **error);

Parses the complete input without recovering missing or quoted disposition tokens 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 around the disposition atom. Each non-ASCII atom byte becomes '?' following ASCII decoding. Parameters use the compliance and duplicate precedence rules of g_mime_param_list_parse_full().

Parameters

options

parser options, or NULL for the defaults.

[nullable]

str

Content-Disposition field value

 

length

byte length, or -1 for a NUL-terminated string

 

error

return location for a GError.

[nullable]

Returns

the parsed disposition, or NULL on error.

[nullable][transfer full]


g_mime_content_disposition_clone ()

GMimeContentDisposition *
g_mime_content_disposition_clone (GMimeContentDisposition *disposition);

Copies the disposition 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. Legacy disposition text is preserved.

Parameters

disposition

a GMimeContentDisposition

 

Returns

an independent copy of disposition .

[transfer full]


g_mime_content_disposition_to_string ()

char *
g_mime_content_disposition_to_string (GMimeContentDisposition *disposition);

Formats a display string beginning with "Content-Disposition: ". 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_disposition_encode() when serializing a MIME message.

Parameters

disposition

a GMimeContentDisposition

 

Returns

the unencoded display string.

[transfer full]


g_mime_content_disposition_is_attachment ()

gboolean
g_mime_content_disposition_is_attachment
                               (GMimeContentDisposition *disposition);

Determines if a Content-Disposition has a value of "attachment".

Parameters

disposition

a GMimeContentDisposition object

 

Returns

TRUE if the value matches "attachment", otherwise FALSE.


g_mime_content_disposition_set_is_attachment ()

void
g_mime_content_disposition_set_is_attachment
                               (GMimeContentDisposition *disposition,
                                gboolean attachment);

Sets the disposition to the lowercase "attachment" or "inline" token. Existing parameters are retained. Changes notify owning entities, while assigning an identical token leaves raw headers untouched.

Parameters

disposition

a GMimeContentDisposition

 

attachment

TRUE for attachment, or FALSE for inline

 

g_mime_content_disposition_set_disposition ()

void
g_mime_content_disposition_set_disposition
                               (GMimeContentDisposition *disposition,
                                const char *value);

Sets the disposition to value which may be one of GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE or, by your choice, any other string which would indicate how the MIME part should be displayed by the MUA.

Parameters

disposition

a GMimeContentDisposition object

 

value

disposition value

 

g_mime_content_disposition_get_disposition ()

const char *
g_mime_content_disposition_get_disposition
                               (GMimeContentDisposition *disposition);

Gets the disposition or NULL on fail.

Parameters

disposition

a GMimeContentDisposition object

 

Returns

the disposition string which is probably one of GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE.


g_mime_content_disposition_get_filename ()

const char *
g_mime_content_disposition_get_filename
                               (GMimeContentDisposition *disposition);

Gets the filename parameter without falling back to an owning entity's Content-Type name parameter.

Parameters

disposition

a GMimeContentDisposition

 

Returns

the borrowed UTF-8 filename, or NULL if absent.

[nullable]


g_mime_content_disposition_set_filename ()

void
g_mime_content_disposition_set_filename
                               (GMimeContentDisposition *disposition,
                                const char *filename);

Sets the filename parameter without trimming or otherwise normalizing it. An empty string remains an explicit empty value. This does not also set the name parameter on an owning entity's Content-Type.

Parameters

disposition

a GMimeContentDisposition

 

filename

the UTF-8 filename, or NULL to remove the parameter.

[nullable]

g_mime_content_disposition_get_creation_date ()

GDateTime *
g_mime_content_disposition_get_creation_date
                               (GMimeContentDisposition *disposition);

Decodes the creation-date parameter without modifying its stored text.

Parameters

disposition

a GMimeContentDisposition

 

Returns

a newly allocated date, or NULL if the parameter is absent, empty, or cannot be parsed. Free with g_date_time_unref().

[transfer full][nullable]


g_mime_content_disposition_set_creation_date ()

void
g_mime_content_disposition_set_creation_date
                               (GMimeContentDisposition *disposition,
                                GDateTime *date);

Sets the creation-date parameter using g_mime_utils_header_format_date(). The date is formatted to whole seconds; no reference to date is retained. Existing parameter metadata is preserved and changes notify owning entities.

Parameters

disposition

a GMimeContentDisposition

 

date

the creation date, or NULL to remove the parameter.

[nullable]

g_mime_content_disposition_get_modification_date ()

GDateTime *
g_mime_content_disposition_get_modification_date
                               (GMimeContentDisposition *disposition);

Decodes the modification-date parameter without modifying its stored text.

Parameters

disposition

a GMimeContentDisposition

 

Returns

a newly allocated date, or NULL if the parameter is absent, empty, or cannot be parsed. Free with g_date_time_unref().

[transfer full][nullable]


g_mime_content_disposition_set_modification_date ()

void
g_mime_content_disposition_set_modification_date
                               (GMimeContentDisposition *disposition,
                                GDateTime *date);

Sets the modification-date parameter using g_mime_utils_header_format_date(). The date is formatted to whole seconds; no reference to date is retained. Existing parameter metadata is preserved and changes notify owning entities.

Parameters

disposition

a GMimeContentDisposition

 

date

the modification date, or NULL to remove the parameter.

[nullable]

g_mime_content_disposition_get_read_date ()

GDateTime *
g_mime_content_disposition_get_read_date
                               (GMimeContentDisposition *disposition);

Decodes the read-date parameter without modifying its stored text.

Parameters

disposition

a GMimeContentDisposition

 

Returns

a newly allocated date, or NULL if the parameter is absent, empty, or cannot be parsed. Free with g_date_time_unref().

[transfer full][nullable]


g_mime_content_disposition_set_read_date ()

void
g_mime_content_disposition_set_read_date
                               (GMimeContentDisposition *disposition,
                                GDateTime *date);

Sets the read-date parameter using g_mime_utils_header_format_date(). The date is formatted to whole seconds; no reference to date is retained. Existing parameter metadata is preserved and changes notify owning entities.

Parameters

disposition

a GMimeContentDisposition

 

date

the last-read date, or NULL to remove the parameter.

[nullable]

g_mime_content_disposition_get_size ()

gint64
g_mime_content_disposition_get_size (GMimeContentDisposition *disposition);

Gets the size parameter without modifying its stored text. Only ASCII decimal digits are accepted; signs, whitespace, and values greater than G_MAXINT64 are invalid. Leading zeros are allowed.

Parameters

disposition

a GMimeContentDisposition

 

Returns

the nonnegative size in bytes, or -1 if the parameter is absent, empty, or invalid.


g_mime_content_disposition_set_size ()

void
g_mime_content_disposition_set_size (GMimeContentDisposition *disposition,
                                     gint64 size);

Sets the size parameter to a nonnegative decimal integer. Values below -1 are invalid. Existing parameter metadata is preserved and changes notify owning entities.

Parameters

disposition

a GMimeContentDisposition

 

size

the size in bytes, or -1 to remove the parameter

 

g_mime_content_disposition_get_parameters ()

GMimeParamList *
g_mime_content_disposition_get_parameters
                               (GMimeContentDisposition *disposition);

Gets the Content-Disposition parameter list.

Parameters

disposition

a GMimeContentDisposition object

 

Returns

the Content-Disposition's parameter list.

[transfer none]


g_mime_content_disposition_set_parameter ()

void
g_mime_content_disposition_set_parameter
                               (GMimeContentDisposition *disposition,
                                const char *name,
                                const char *value);

Sets a parameter on the Content-Disposition.

Note: The name should be in US-ASCII while the value should be in UTF-8.

Parameters

disposition

a GMimeContentDisposition object

 

name

parameter name

 

value

parameter value

 

g_mime_content_disposition_get_parameter ()

const char *
g_mime_content_disposition_get_parameter
                               (GMimeContentDisposition *disposition,
                                const char *name);

Gets the parameter value specified by name if it's available.

Parameters

disposition

a GMimeContentDisposition object

 

name

parameter name

 

Returns

the value of the requested parameter or NULL if the parameter is not set. If the parameter is set, the returned string will be in UTF-8.


g_mime_content_disposition_encode ()

char *
g_mime_content_disposition_encode (GMimeContentDisposition *disposition,
                                   GMimeFormatOptions *options);

Encodes the Content-Disposition field value, including leading whitespace and a terminating newline. The field name is not included.

Parameters

disposition

a GMimeContentDisposition object

 

options

a GMimeFormatOptions or NULL.

[nullable]

Returns

a new string containing the encoded header value.

Types and Values

GMIME_DISPOSITION_ATTACHMENT

#define GMIME_DISPOSITION_ATTACHMENT "attachment"

Standard attachment disposition.


GMIME_DISPOSITION_INLINE

#define GMIME_DISPOSITION_INLINE     "inline"

Standard inline disposition.


GMimeContentDisposition

typedef struct _GMimeContentDisposition GMimeContentDisposition;

A data structure representing a Content-Disposition.