| Top |
A GMimeParam is a parameter name/value pair as found on MIME header fields such as Content-Type and Content-Disposition.
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.
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.
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.
const char *
g_mime_param_get_name (GMimeParam *param);
Gets the name of the parameter.
const char *
g_mime_param_get_value (GMimeParam *param);
Gets the value of the parameter.
void g_mime_param_set_value (GMimeParam *param,const char *value);
Sets the parameter value to value
.
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.
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.
const char *
g_mime_param_get_lang (GMimeParam *param);
Gets the language specifier used for encoding the parameter.
void g_mime_param_set_lang (GMimeParam *param,const char *lang);
Sets the parameter language specifier used for encoding the value.
GMimeParamEncodingMethod
g_mime_param_get_encoding_method (GMimeParam *param);
Gets the encoding method used for encoding the parameter.
void g_mime_param_set_encoding_method (GMimeParam *param,GMimeParamEncodingMethod method);
Sets the encoding method used for encoding the value.
gboolean
g_mime_param_get_always_quote (GMimeParam *param);
Gets whether an otherwise unquoted parameter value should be quoted.
The default is FALSE.
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.
GMimeParamList *
g_mime_param_list_new (void);
Creates a new Content-Type or Content-Disposition parameter list.
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.
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.
void
g_mime_param_list_clear (GMimeParamList *list);
Clears the list of parameters.
int
g_mime_param_list_length (GMimeParamList *list);
Gets the length of the list.
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.
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.
list |
||
index |
an index from zero through the list length, inclusive |
|
param |
a GMimeParam. |
[transfer none] |
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.
int g_mime_param_list_index_of (GMimeParamList *list,const char *name);
int g_mime_param_list_index_of_parameter (GMimeParamList *list,GMimeParam *param);
gboolean g_mime_param_list_contains (GMimeParamList *list,const char *name);
gboolean g_mime_param_list_contains_parameter (GMimeParamList *list,GMimeParam *param);
void g_mime_param_list_set_parameter (GMimeParamList *list,const char *name,const char *value);
Sets the specified parameter to value
.
GMimeParam * g_mime_param_list_get_parameter (GMimeParamList *list,const char *name);
Gets the GMimeParam with the given name
.
GMimeParam * g_mime_param_list_get_parameter_at (GMimeParamList *list,int index);
Gets the GMimeParam at the specified index
.
gboolean g_mime_param_list_remove (GMimeParamList *list,const char *name);
Removes a parameter from the GMimeParamList.
gboolean g_mime_param_list_remove_parameter (GMimeParamList *list,GMimeParam *param);
Removes only this exact object, not another parameter with the same name.
gboolean g_mime_param_list_remove_at (GMimeParamList *list,int index);
Removes a GMimeParam from the GMimeParamList at the specified index.
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.
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.
list |
||
options |
a GMimeFormatOptions or |
[nullable] |
fold |
|
|
str |
the output string buffer. |
[out] |