Top Level Domain utils

## Top Level Domain utils Top Level Domain utils |

## Synopsis

    #include <libsoup/soup.h>

    const char *        soup_tld_get_base_domain            (const char *hostname,
                                                             GError **error);
    gboolean            soup_tld_domain_is_public_suffix    (const char *domain);

    #define             SOUP_TLD_ERROR
    enum                SoupTLDError;

## Description

## Details

### soup_tld_get_base_domain ()

    const char *        soup_tld_get_base_domain            (const char *hostname,
                                                             GError **error);

Finds the base domain for a given `hostname`. The base domain is composed by the top level domain (such as .org, .com, .co.uk, etc) plus the second level domain, for example for myhost.mydomain.com it will return mydomain.com.

Note that `NULL` will be returned for private URLs (those not ending with any well known TLD) because choosing a base domain for them would be totally arbitrary.

This method only works for valid UTF-8 hostnames in their canonical representation form, so you should use `g_hostname_to_unicode()` to get the canonical representation if that is not the case.

`hostname` : | a UTF-8 hostname in its canonical representation form
`error` : | return location for a GError, or `NULL` to ignore errors. See SoupTLDError for the available error codes
Returns : | a pointer to the start of the base domain in `hostname`. If an error occurs, `NULL` will be returned and `error` set.

Since 2.40

### soup_tld_domain_is_public_suffix ()

    gboolean            soup_tld_domain_is_public_suffix    (const char *domain);

Looks whether the `domain` passed as argument is a public domain suffix (.org, .com, .co.uk, etc) or not.

This method only works for valid UTF-8 domains in their canonical representation form, so you should use `g_hostname_to_unicode()` to get the canonical representation if that is not the case.

`domain` : | a UTF-8 domain in its canonical representation form
Returns : | `TRUE` if it is a public domain, `FALSE` otherwise.

Since 2.40

### SOUP_TLD_ERROR

    #define SOUP_TLD_ERROR soup_tld_error_quark()

### enum SoupTLDError

    typedef enum {
    	SOUP_TLD_ERROR_INVALID_HOSTNAME,
    	SOUP_TLD_ERROR_IS_IP_ADDRESS,
    	SOUP_TLD_ERROR_NOT_ENOUGH_DOMAINS,
    	SOUP_TLD_ERROR_NO_BASE_DOMAIN
    } SoupTLDError;