GMimeContentType

## GMimeContentType GMimeContentType — Content-Type fields |

## Functions

GMimeContentType * | g_mime_content_type_new ()
GMimeContentType * | g_mime_content_type_new_from_string ()
char * | g_mime_content_type_to_string ()
gboolean | g_mime_content_type_is_type ()
const char * | g_mime_content_type_get_media_type ()
void | g_mime_content_type_set_media_type ()
const char * | g_mime_content_type_get_media_subtype ()
void | g_mime_content_type_set_media_subtype ()
const GMimeParam * | g_mime_content_type_get_params ()
void | g_mime_content_type_set_params ()
const char * | g_mime_content_type_get_parameter ()
void | g_mime_content_type_set_parameter ()

## Types and Values

struct | GMimeContentType

## Description

A GMimeContentType represents the pre-parsed contents of a Content-Type header field.

## Functions

### g_mime_content_type_new ()

    GMimeContentType *
    g_mime_content_type_new (const char *type,
                             const char *subtype);

Creates a Content-Type object with type `type` and subtype `subtype` .

#### Parameters

type | MIME type (or `NULL` for "text") |
subtype | MIME subtype (or `NULL` for "plain") |

#### Returns

a new GMimeContentType object.

### g_mime_content_type_new_from_string ()

    GMimeContentType *
    g_mime_content_type_new_from_string (const char *str);

Constructs a new Content-Type object based on the input string.

#### Parameters

str | input string containing a content-type (and params) |

#### Returns

a new GMimeContentType object based on the input string.

### g_mime_content_type_to_string ()

    char *
    g_mime_content_type_to_string (GMimeContentType *mime_type);

Allocates a string buffer containing the type and subtype defined by the `mime_type` .

#### Parameters

mime_type | a GMimeContentType object |

#### Returns

an allocated string containing the type and subtype of the content-type in the format: type/subtype.

### g_mime_content_type_is_type ()

    gboolean
    g_mime_content_type_is_type (GMimeContentType *mime_type,
                                 const char *type,
                                 const char *subtype);

Compares the given type and subtype with that of the given mime type object.

#### Parameters

mime_type | a GMimeContentType object |
type | MIME type to compare against |
subtype | MIME subtype to compare against |

#### Returns

TRUE if the MIME types match or FALSE otherwise. You may use "*" in place of `type` and/or `subtype` as a wilcard.

### g_mime_content_type_get_media_type ()

    const char *
    g_mime_content_type_get_media_type (GMimeContentType *mime_type);

Gets the Content-Type's media type.

#### Parameters

mime_type | a GMimeContentType object |

#### Returns

the Content-Type's media type.

### g_mime_content_type_set_media_type ()

    void
    g_mime_content_type_set_media_type (GMimeContentType *mime_type,
                                        const char *type);

Sets the Content-Type's media type.

#### Parameters

mime_type | a GMimeContentType object |
type | media type |

### g_mime_content_type_get_media_subtype ()

    const char *
    g_mime_content_type_get_media_subtype (GMimeContentType *mime_type);

Gets the Content-Type's media sub-type.

#### Parameters

mime_type | a GMimeContentType object |

#### Returns

the Content-Type's media sub-type.

### g_mime_content_type_set_media_subtype ()

    void
    g_mime_content_type_set_media_subtype (GMimeContentType *mime_type,
                                           const char *subtype);

Sets the Content-Type's media subtype.

#### Parameters

mime_type | a GMimeContentType object |
subtype | media subtype |

### g_mime_content_type_get_params ()

    const GMimeParam *
    g_mime_content_type_get_params (GMimeContentType *mime_type);

Gets the Content-Type's parameter list.

#### Parameters

mime_type | a GMimeContentType object |

#### Returns

the Content-Type's parameter list.

### g_mime_content_type_set_params ()

    void
    g_mime_content_type_set_params (GMimeContentType *mime_type,
                                    GMimeParam *params);

Sets the Content-Type's parameter list.

#### Parameters

mime_type | a GMimeContentType object |
params | a list of GMimeParam objects |

### g_mime_content_type_get_parameter ()

    const char *
    g_mime_content_type_get_parameter (GMimeContentType *mime_type,
                                       const char *attribute);

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

#### Parameters

mime_type | a GMimeContentType object |
name | parameter name (aka attribute) |

#### 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_type_set_parameter ()

    void
    g_mime_content_type_set_parameter (GMimeContentType *mime_type,
                                       const char *attribute,
                                       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.

#### Parameters

mime_type | MIME Content-Type |
name | parameter name (aka attribute) |
value | parameter value |

## Types and Values

### struct GMimeContentType

    struct GMimeContentType {
    	GObject parent_object;

    	GHashTable *param_hash;
    	GMimeParam *params;

    	gpointer priv;

    	char *type;
    	char *subtype;
    };

A data structure representing a Content-Type.

#### Members

GObject `parent_object`; | parent GObject |
GHashTable *`param_hash`; | parameter hash keyed by param name |
GMimeParam *`params`; | a GMimeParam list |
gpointer `priv`; |  |
char *`type`; | media type |
char *`subtype`; | media subtype |