## internet-address

internet-address —

## Synopsis

    enum        InternetAddressType;
    struct      InternetAddressList;
    struct      InternetAddress;
    InternetAddress* internet_address_new       (void);
    InternetAddress* internet_address_new_name  (const char *name,
                                                 const char *addr);
    InternetAddress* internet_address_new_group (const char *name);
    void        internet_address_ref            (InternetAddress *ia);
    void        internet_address_unref          (InternetAddress *ia);
    void        internet_address_set_name       (InternetAddress *ia,
                                                 const char *name);
    void        internet_address_set_addr       (InternetAddress *ia,
                                                 const char *addr);
    void        internet_address_set_group      (InternetAddress *ia,
                                                 InternetAddressList *group);
    void        internet_address_add_member     (InternetAddress *ia,
                                                 InternetAddress *member);
    InternetAddressList* internet_address_list_prepend
                                                (InternetAddressList *list,
                                                 InternetAddress *ia);
    InternetAddressList* internet_address_list_append
                                                (InternetAddressList *list,
                                                 InternetAddress *ia);
    InternetAddressList* internet_address_list_concat
                                                (InternetAddressList *a,
                                                 InternetAddressList *b);
    int         internet_address_list_length    (const InternetAddressList *list);
    void        internet_address_list_destroy   (InternetAddressList *list);
    InternetAddressList* internet_address_parse_string
                                                (const char *string);
    char*       internet_address_to_string      (const InternetAddress *ia,
                                                 gboolean encode);
    char*       internet_address_list_to_string (const InternetAddressList *list,
                                                 gboolean encode);

## Description

## Details

### enum InternetAddressType

    typedef enum {
    	INTERNET_ADDRESS_NONE,
    	INTERNET_ADDRESS_NAME,
    	INTERNET_ADDRESS_GROUP
    } InternetAddressType;

### struct InternetAddressList

    struct InternetAddressList {

    	struct _InternetAddressList *next;
    	InternetAddress *address;
    };

### struct InternetAddress

    struct InternetAddress {

    	InternetAddressType type;
    	unsigned int refcount;
    	char *name;
    	union {
    		char *addr;
    		InternetAddressList *members;
    	} value;
    };

### internet_address_new ()

    InternetAddress* internet_address_new       (void);

Creates a new InternetAddress object

Returns : | a new InternetAddress object.

### internet_address_new_name ()

    InternetAddress* internet_address_new_name  (const char *name,
                                                 const char *addr);

Creates a new InternetAddress object with name `name` and address `addr`.

`name` : | person's name
`addr` : | person's address
Returns : | a new InternetAddress object.

### internet_address_new_group ()

    InternetAddress* internet_address_new_group (const char *name);

Creates a new InternetAddress object with group name `name`.

`name` : | group name
Returns : | a new InternetAddress object.

### internet_address_ref ()

    void        internet_address_ref            (InternetAddress *ia);

Ref's the internet address.

`ia` : | internet address

### internet_address_unref ()

    void        internet_address_unref          (InternetAddress *ia);

Unref's the internet address.

`ia` : | internet address

### internet_address_set_name ()

    void        internet_address_set_name       (InternetAddress *ia,
                                                 const char *name);

Set the name of the internet address.

`ia` : | internet address
`name` : | group or contact's name

### internet_address_set_addr ()

    void        internet_address_set_addr       (InternetAddress *ia,
                                                 const char *addr);

Set the internet address's address.

`ia` : | internet address
`addr` : | contact's email address

### internet_address_set_group ()

    void        internet_address_set_group      (InternetAddress *ia,
                                                 InternetAddressList *group);

Set the members of the internet address group.

`ia` : | internet address
`group` : | a list of internet addresses

### internet_address_add_member ()

    void        internet_address_add_member     (InternetAddress *ia,
                                                 InternetAddress *member);

Add a contact to the internet address group.

`ia` : | internet address
`member` : | group member's internet address

### internet_address_list_prepend ()

    InternetAddressList* internet_address_list_prepend
                                                (InternetAddressList *list,
                                                 InternetAddress *ia);

Prepends the internet address to the list of internet addresses pointed to by `list`.

`list` : | a list of internet addresses
`ia` : | internet address to prepend
Returns : | the resultant list.

### internet_address_list_append ()

    InternetAddressList* internet_address_list_append
                                                (InternetAddressList *list,
                                                 InternetAddress *ia);

Appends the internet address to the list of internet addresses pointed to by `list`.

`list` : | a list of internet addresses
`ia` : | internet address to append
Returns : | the resultant list.

### internet_address_list_concat ()

    InternetAddressList* internet_address_list_concat
                                                (InternetAddressList *a,
                                                 InternetAddressList *b);

Concatenates a copy of list `b` onto the end of list `a`.

`a` : | first list
`b` : | second list
Returns : | the resulting list.

### internet_address_list_length ()

    int         internet_address_list_length    (const InternetAddressList *list);

Calculates the length of the list of addresses.

`list` : | list of internet addresses
Returns : | the number of internet addresses in `list`.

### internet_address_list_destroy ()

    void        internet_address_list_destroy   (InternetAddressList *list);

Destroys the list of internet addresses.

`list` : | address list

### internet_address_parse_string ()

    InternetAddressList* internet_address_parse_string
                                                (const char *string);

Construct a list of internet addresses from the given string.

`string` : | a string containing internet addresses
Returns : | a linked list of internet addresses. *Must* be free'd by the caller.

### internet_address_to_string ()

    char*       internet_address_to_string      (const InternetAddress *ia,
                                                 gboolean encode);

Allocates a string containing the contents of the InternetAddress object.

`ia` : | Internet Address object
`encode` : | TRUE if the address should be rfc2047 encoded
Returns : | the InternetAddress object as an allocated string in rfc822 format.

### internet_address_list_to_string ()

    char*       internet_address_list_to_string (const InternetAddressList *list,
                                                 gboolean encode);

Allocates a string buffer containing the rfc822 formatted addresses in `list`.

`list` : | list of internet addresses
`encode` : | `TRUE` if the address should be rfc2047 encoded
Returns : | a string containing the list of addresses in rfc822 format.