GMimeParamList

GMimeParamList — Content-Type and Content-Disposition parameters

Functions

Types and Values

Description

A GMimeParam is a parameter name/value pair as found on MIME header fields such as Content-Type and Content-Disposition.

Functions

g_mime_param_new ()

GMimeParam *
g_mime_param_new (const char *name,
                  const char *value);

Creates a parameter with the default encoding method and charset. Invalid names and invalid UTF-8 values are programming errors.

Parameters

name

a nonempty ASCII parameter name containing only attribute characters

 

value

a UTF-8 parameter value, possibly empty

 

Returns

a new GMimeParam.

[transfer full]


g_mime_param_clone ()

GMimeParam *
g_mime_param_clone (GMimeParam *param);

Copies the name, value, preferred charset, language, encoding method, and quoting preference. Changes to the clone do not affect param or its owning lists.

Parameters

param

a GMimeParam

 

Returns

an independent copy of param .

[transfer full]


g_mime_param_to_string ()

char *
g_mime_param_to_string (GMimeParam *param);

Formats the parameter as name="value", always quoting the value and escaping quotes and backslashes. No transport encoding or folding is performed.

Parameters

param

a GMimeParam

 

Returns

the display string.

[transfer full]


g_mime_param_get_name ()

const char *
g_mime_param_get_name (GMimeParam *param);

Gets the name of the parameter.

Parameters

param

a GMimeParam

 

Returns

the name of the parameter.


g_mime_param_get_value ()

const char *
g_mime_param_get_value (GMimeParam *param);

Gets the value of the parameter.

Parameters

param

a GMimeParam

 

Returns

the value of the parameter.


g_mime_param_set_value ()

void
g_mime_param_set_value (GMimeParam *param,
                        const char *value);

Sets the parameter value to value .

Parameters

param

a GMimeParam

 

value

the new parameter value

 

g_mime_param_get_charset ()

const char *
g_mime_param_get_charset (GMimeParam *param);

Gets the configured or parsed parameter charset. RFC 2231 and RFC 2047 serialization choose ASCII or Latin-1 for values representable in those charsets, otherwise use this charset or UTF-8 if it cannot encode the value.

Parameters

param

a GMimeParam

 

Returns

the configured or parsed charset, or NULL for the default.

[nullable]


g_mime_param_set_charset ()

void
g_mime_param_set_charset (GMimeParam *param,
                          const char *charset);

Sets the preferred parameter charset. RFC 2231 and RFC 2047 serialization use this charset for values outside Latin-1 if it preserves the complete value, otherwise falls back to UTF-8. NULL selects UTF-8 for those values.

Parameters

param

a GMimeParam

 

charset

the charset or NULL to use the default

 

g_mime_param_get_lang ()

const char *
g_mime_param_get_lang (GMimeParam *param);

Gets the language specifier used for encoding the parameter.

Parameters

param

a GMimeParam

 

Returns

the language specifier used for encoding the parameter.


g_mime_param_set_lang ()

void
g_mime_param_set_lang (GMimeParam *param,
                       const char *lang);

Sets the parameter language specifier used for encoding the value.

Parameters

param

a GMimeParam

 

lang

the language specifier

 

g_mime_param_get_encoding_method ()

GMimeParamEncodingMethod
g_mime_param_get_encoding_method (GMimeParam *param);

Gets the encoding method used for encoding the parameter.

Parameters

param

a GMimeParam

 

Returns

the encoding method used for encoding the parameter.


g_mime_param_set_encoding_method ()

void
g_mime_param_set_encoding_method (GMimeParam *param,
                                  GMimeParamEncodingMethod method);

Sets the encoding method used for encoding the value.

Parameters

param

a GMimeParam

 

method

a GMimeParamEncodingMethod

 

g_mime_param_get_always_quote ()

gboolean
g_mime_param_get_always_quote (GMimeParam *param);

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

Parameters

param

a GMimeParam

 

Returns

TRUE if quoting is requested for this parameter.


g_mime_param_set_always_quote ()

void
g_mime_param_set_always_quote (GMimeParam *param,
                               gboolean always_quote);

Requests quoting for this parameter in addition to the format option. FALSE does not override the format option or suppress required quoting. RFC 2231 encoded values are not quoted.

Parameters

param

a GMimeParam

 

always_quote

whether to quote otherwise unquoted parameter values

 

g_mime_param_list_new ()

GMimeParamList *
g_mime_param_list_new (void);

Creates a new Content-Type or Content-Disposition parameter list.

Returns

a new GMimeParamList.


g_mime_param_list_parse ()

GMimeParamList *
g_mime_param_list_parse (GMimeParserOptions *options,
                         const char *str);

Parses the input string into a parameter list using best-effort recovery. Duplicate names are retained and malformed suffixes may be ignored. Use g_mime_param_list_parse_full() for all-or-nothing parsing. Comments after unquoted values are ignored; literal parentheses must be quoted or encoded.

Parameters

options

a GMimeParserOptions or NULL

 

str

a string to parse

 

Returns

a new GMimeParamList.

[transfer full]


g_mime_param_list_parse_full ()

GMimeParamList *
g_mime_param_list_parse_full (GMimeParserOptions *options,
                              const char *str,
                              gssize length,
                              GError **error);

Parses the complete input, returning NULL with GMIME_ERROR_PARSE_ERROR and a byte offset on malformed input. Explicitly bounded input need not be NUL-terminated but cannot contain embedded NUL bytes. Empty lists and empty semicolon-delimited entries are accepted. NULs produced by decoding encoded values are replaced with U+FFFD.

Strict parameter compliance requires semicolon separators. Loose modes also accept missing separators after quoted values and unquoted values containing spaces. Comments after unquoted values are ignored; literal parentheses must be quoted or encoded. Unterminated comments and quoted values are errors in every mode.

Names are matched case-insensitively. The first ordinary value wins, but an RFC 2231 value overrides it. Repeated standalone RFC 2231 values use the last value; numbered continuations are combined in numeric order. The first occurrence determines the parameter's position and name spelling.

Parameters

options

parser options, or NULL for the defaults.

[nullable]

str

parameter-list text

 

length

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

 

error

return location for a GError.

[nullable]

Returns

the parsed list, or NULL on error.

[nullable][transfer full]


g_mime_param_list_clear ()

void
g_mime_param_list_clear (GMimeParamList *list);

Clears the list of parameters.

Parameters

list

a GMimeParamList

 

g_mime_param_list_length ()

int
g_mime_param_list_length (GMimeParamList *list);

Gets the length of the list.

Parameters

list

a GMimeParamList

 

Returns

the number of GMimeParam items in the list.


g_mime_param_list_add ()

int
g_mime_param_list_add (GMimeParamList *list,
                       GMimeParam *param);

Appends param , retaining a reference and observing its changes. A parameter with the same case-insensitive name must not already exist.

Parameters

list

a GMimeParamList

 

param

a GMimeParam.

[transfer none]

Returns

the added index, or -1 on a programming error.


g_mime_param_list_insert ()

void
g_mime_param_list_insert (GMimeParamList *list,
                          int index,
                          GMimeParam *param);

Inserts param , retaining a reference and observing its changes. A parameter with the same case-insensitive name must not already exist.

Parameters

list

a GMimeParamList

 

index

an index from zero through the list length, inclusive

 

param

a GMimeParam.

[transfer none]

g_mime_param_list_set_parameter_at ()

void
g_mime_param_list_set_parameter_at (GMimeParamList *list,
                                    int index,
                                    GMimeParam *param);

Replaces an entry, retaining a reference to param . A different name must not duplicate another entry's case-insensitive name. Assigning the same object does not emit a change.

Parameters

list

a GMimeParamList

 

index

an existing index

 

param

the replacement GMimeParam.

[transfer none]

g_mime_param_list_index_of ()

int
g_mime_param_list_index_of (GMimeParamList *list,
                            const char *name);

Parameters

list

a GMimeParamList

 

name

the parameter name

 

Returns

the first case-insensitive name match, or -1 if absent.


g_mime_param_list_index_of_parameter ()

int
g_mime_param_list_index_of_parameter (GMimeParamList *list,
                                      GMimeParam *param);

Parameters

list

a GMimeParamList

 

param

a GMimeParam

 

Returns

the first index of this exact object, or -1 if absent.


g_mime_param_list_contains ()

gboolean
g_mime_param_list_contains (GMimeParamList *list,
                            const char *name);

Parameters

list

a GMimeParamList

 

name

the parameter name

 

Returns

whether a parameter with this case-insensitive name exists.


g_mime_param_list_contains_parameter ()

gboolean
g_mime_param_list_contains_parameter (GMimeParamList *list,
                                      GMimeParam *param);

Parameters

list

a GMimeParamList

 

param

a GMimeParam

 

Returns

whether this exact object is in the list.


g_mime_param_list_set_parameter ()

void
g_mime_param_list_set_parameter (GMimeParamList *list,
                                 const char *name,
                                 const char *value);

Sets the specified parameter to value .

Parameters

list

a GMimeParamList

 

name

The name of the parameter

 

value

The parameter value

 

g_mime_param_list_get_parameter ()

GMimeParam *
g_mime_param_list_get_parameter (GMimeParamList *list,
                                 const char *name);

Gets the GMimeParam with the given name .

Parameters

list

list: a GMimeParamList

 

name

the name of the parameter

 

Returns

the requested GMimeParam.

[transfer none]


g_mime_param_list_get_parameter_at ()

GMimeParam *
g_mime_param_list_get_parameter_at (GMimeParamList *list,
                                    int index);

Gets the GMimeParam at the specified index .

Parameters

list

a GMimeParamList

 

index

the index of the requested parameter

 

Returns

the GMimeParam at the specified index.

[transfer none]


g_mime_param_list_remove ()

gboolean
g_mime_param_list_remove (GMimeParamList *list,
                          const char *name);

Removes a parameter from the GMimeParamList.

Parameters

list

a GMimeParamList

 

name

the name of the parameter

 

Returns

TRUE if the specified parameter was removed or FALSE otherwise.


g_mime_param_list_remove_parameter ()

gboolean
g_mime_param_list_remove_parameter (GMimeParamList *list,
                                    GMimeParam *param);

Removes only this exact object, not another parameter with the same name.

Parameters

list

a GMimeParamList

 

param

a GMimeParam

 

Returns

whether param was removed.


g_mime_param_list_remove_at ()

gboolean
g_mime_param_list_remove_at (GMimeParamList *list,
                             int index);

Removes a GMimeParam from the GMimeParamList at the specified index.

Parameters

list

a GMimeParamList

 

index

index of the param to remove

 

Returns

TRUE if a GMimeParam was removed or FALSE otherwise.


g_mime_param_list_to_string ()

char *
g_mime_param_list_to_string (GMimeParamList *list);

Formats parameters in order, each prefixed by "; " and with its value quoted and escaped. No transport encoding or folding is performed.

Parameters

list

a GMimeParamList

 

Returns

the display string, or an empty string for an empty list.

[transfer full]


g_mime_param_list_encode ()

void
g_mime_param_list_encode (GMimeParamList *list,
                          GMimeFormatOptions *options,
                          gboolean fold,
                          GString *str);

Encodes the parameter list into str , folding lines if required. Parameter values must be valid UTF-8. When international formatting is enabled, ordinary Unicode values are quoted without transport encoding and long RFC 2231 values may use unencoded UTF-8 continuations. Controls and values resembling encoded words still require transport encoding.

Parameters

list

a GMimeParamList

 

options

a GMimeFormatOptions or NULL.

[nullable]

fold

TRUE if the parameter list should be folded; otherwise, FALSE

 

str

the output string buffer.

[out]

Types and Values

GMimeParam

typedef struct _GMimeParam GMimeParam;

A parameter name/value pair as used in the Content-Type and Content-Disposition headers.


GMimeParamList

typedef struct _GMimeParamList GMimeParamList;

A list of Content-Type or Content-Disposition parameters.

See Also

GMimeContentType