## GMimeHeader GMimeHeader — Message and MIME part headers |

## Synopsis

                        GMimeHeader;
    void                (*GMimeHeaderForeachFunc)           (const char *name,
                                                             const char *value,
                                                             gpointer user_data);
    ssize_t             (*GMimeHeaderWriter)                (GMimeStream *stream,
                                                             const char *name,
                                                             const char *value);
    GMimeHeader*        g_mime_header_new                   (void);
    void                g_mime_header_destroy               (GMimeHeader *header);
    void                g_mime_header_add                   (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);
    void                g_mime_header_prepend               (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);
    void                g_mime_header_set                   (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);
    const char*         g_mime_header_get                   (const GMimeHeader *header,
                                                             const char *name);
    void                g_mime_header_remove                (GMimeHeader *header,
                                                             const char *name);
    ssize_t             g_mime_header_write_to_stream       (const GMimeHeader *header,
                                                             GMimeStream *stream);
    char*               g_mime_header_to_string             (const GMimeHeader *header);
    void                g_mime_header_foreach               (const GMimeHeader *header,
                                                             GMimeHeaderForeachFunc func,
                                                             gpointer user_data);
    gboolean            g_mime_header_has_raw               (GMimeHeader *header);
    void                g_mime_header_set_raw               (GMimeHeader *header,
                                                             const char *raw);
    void                g_mime_header_register_writer       (GMimeHeader *header,
                                                             const char *name,
                                                             GMimeHeaderWriter writer);

## Description

A GMimeHeader is a collection of rfc822 header fields and their values.

## Details

### GMimeHeader

    typedef struct _GMimeHeader GMimeHeader;

A message or mime-part header.

### GMimeHeaderForeachFunc ()

    void                (*GMimeHeaderForeachFunc)           (const char *name,
                                                             const char *value,
                                                             gpointer user_data);

Function signature for the callback to `g_mime_header_foreach()`.

`name` : | The field name.
`value` : | The field value.
`user_data` : | The user-supplied callback data.

### GMimeHeaderWriter ()

    ssize_t             (*GMimeHeaderWriter)                (GMimeStream *stream,
                                                             const char *name,
                                                             const char *value);

Function signature for the callback to `g_mime_header_register_writer()`.

`stream` : | The output stream.
`name` : | The field name.
`value` : | The field value.
Returns : | the number of bytes written or `-1` on error.

### g_mime_header_new ()

    GMimeHeader*        g_mime_header_new                   (void);

Creates a new GMimeHeader object.

Returns : | a new header object.

### g_mime_header_destroy ()

    void                g_mime_header_destroy               (GMimeHeader *header);

Destroy the header object

`header` : | header object

### g_mime_header_add ()

    void                g_mime_header_add                   (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);

Adds a header. If `value` is `NULL`, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

`header` : | header object
`name` : | header name
`value` : | header value

### g_mime_header_prepend ()

    void                g_mime_header_prepend               (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);

Adds a header to the head of the list. If `value` is `NULL`, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

`header` : | header object
`name` : | header name
`value` : | header value

### g_mime_header_set ()

    void                g_mime_header_set                   (GMimeHeader *header,
                                                             const char *name,
                                                             const char *value);

Set the value of the specified header. If `value` is `NULL` and the header, `name`, had not been previously set, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

`header` : | header object
`name` : | header name
`value` : | header value

### g_mime_header_get ()

    const char*         g_mime_header_get                   (const GMimeHeader *header,
                                                             const char *name);

Gets the value of the header requested.

`header` : | header object
`name` : | header name
Returns : | the value of the header requested.

### g_mime_header_remove ()

    void                g_mime_header_remove                (GMimeHeader *header,
                                                             const char *name);

Remove the specified header.

`header` : | header object
`name` : | header name

### g_mime_header_write_to_stream ()

    ssize_t             g_mime_header_write_to_stream       (const GMimeHeader *header,
                                                             GMimeStream *stream);

Write the headers to a stream.

`header` : | header object
`stream` : | output stream
Returns : | the number of bytes written or `-1` on fail.

### g_mime_header_to_string ()

    char*               g_mime_header_to_string             (const GMimeHeader *header);

Allocates a string buffer containing the raw rfc822 headers contained in `header`.

`header` : | header object
Returns : | a string containing the header block

### g_mime_header_foreach ()

    void                g_mime_header_foreach               (const GMimeHeader *header,
                                                             GMimeHeaderForeachFunc func,
                                                             gpointer user_data);

Calls `func` for each header name/value pair.

`header` : | header object
`func` : | function to be called for each header.
`user_data` : | User data to be passed to the func.

### g_mime_header_has_raw ()

    gboolean            g_mime_header_has_raw               (GMimeHeader *header);

Gets whether or not a raw header has been set on `header`.

`header` : | ehader object
Returns : | `TRUE` if a raw header is set or `FALSE` otherwise.

### g_mime_header_set_raw ()

    void                g_mime_header_set_raw               (GMimeHeader *header,
                                                             const char *raw);

Set the raw header.

`header` : | header object
`raw` : | raw mime part header

### g_mime_header_register_writer ()

    void                g_mime_header_register_writer       (GMimeHeader *header,
                                                             const char *name,
                                                             GMimeHeaderWriter writer);

Changes the function used to write `name` headers to `writer` (or the default if `writer` is `NULL`). This is useful if you want to change the default header folding style for a particular header.

`header` : | header object
`name` : | header name
`writer` : | writer function

## See Also

GMimeObject