## camel-net-utils

camel-net-utils

## Functions

struct addrinfo * | camel_getaddrinfo ()
void | camel_freeaddrinfo ()
gchar * | camel_host_idna_to_ascii ()
gchar * | camel_utils_sanitize_ascii_domain_in_address ()
gchar * | camel_utils_sanitize_ascii_domain_in_url_str ()
gboolean | camel_utils_sanitize_ascii_domain_in_url ()

## Types and Values

#define | socklen_t
struct | addrinfo
#define | AI_CANONNAME
#define | AI_NUMERICHOST
#define | EAI_BADFLAGS
#define | EAI_NONAME
#define | EAI_AGAIN
#define | EAI_FAIL
#define | EAI_NODATA
#define | EAI_FAMILY
#define | EAI_SOCKTYPE
#define | EAI_SERVICE
#define | EAI_ADDRFAMILY
#define | EAI_MEMORY
#define | EAI_SYSTEM
#define | EAI_OVERFLOW
#define | NI_NUMERICHOST
#define | NI_NUMERICSERV
#define | NI_NOFQDN
#define | NI_NAMEREQD
#define | NI_DGRAM
struct | sockaddr

## Description

## Functions

### camel_getaddrinfo ()

    struct addrinfo *
    camel_getaddrinfo (const gchar *name,
                       const gchar *service,
                       const struct addrinfo *hints,
                       GCancellable *cancellable,
                       GError **error);

Resolves a host `name` and returns an information about its address.

#### Parameters

name | an address name to resolve |
service | a service name to use |
hints | an addrinfo hints, or `NULL`. | [nullable]
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

a newly allocated addrinfo. Free it with `camel_freeaddrinfo()` when done with it.

[transfer full][nullable]

Since: 2.22

### camel_freeaddrinfo ()

    void
    camel_freeaddrinfo (struct addrinfo *host);

Frees a structure returned with `camel_getaddrinfo()`. It does nothing when the `host` is `NULL`.

#### Parameters

host | a host address information structure to free, or `NULL`. | [nullable]

Since: 2.22

### camel_host_idna_to_ascii ()

    gchar *
    camel_host_idna_to_ascii (const gchar *host);

Converts IDN (Internationalized Domain Name) into ASCII representation. If there's a failure or the `host` has only ASCII letters, then a copy of `host` is returned.

#### Parameters

host | Host name, with or without non-ascii letters in utf8. | [nullable]

#### Returns

Newly allocated string with only ASCII letters describing the `host` or `NULL`, when the `host` is `NULL`. Free the returned string with `g_free()` when no longer needed.

[nullable]

Since: 3.16

### camel_utils_sanitize_ascii_domain_in_address ()

    gchar *
    camel_utils_sanitize_ascii_domain_in_address
                                   (const gchar *email_address,
                                    gboolean do_format);

Checks whether the domain in the `email_address` requires conversion to ASCII and if it does it also converts it. When the `do_format` is `TRUE`, the output string is formatted for display, otherwise it's encoded for use in the message headers. A `NULL` is returned when no conversion was needed.

#### Parameters

email_address | an email address as string. | [nullable]
do_format | what format will be returned |

#### Returns

the `email_address` with only ASCII letters, if such conversion is needed or `NULL`, when no conversion was required.

See: `camel_hostname_utils_requires_ascii()`, `camel_internet_address_sanitize_ascii_domain()`, `camel_utils_sanitize_ascii_domain_in_url_str()`.

[nullable]

Since: 3.44

### camel_utils_sanitize_ascii_domain_in_url_str ()

    gchar *
    camel_utils_sanitize_ascii_domain_in_url_str
                                   (const gchar *url_str);

Checks whether the host name of the `url_str` requires conversion to ASCII and converts it if needed. Returns `NULL`, when no conversion was required.

#### Parameters

url_str | a URL as string. | [nullable]

#### Returns

converted `url_str` to ASCII host name, or `NULL`, when no conversion was needed.

See: `camel_hostname_utils_requires_ascii()`, `camel_utils_sanitize_ascii_domain_in_url()`.

[nullable]

Since: 3.44

### camel_utils_sanitize_ascii_domain_in_url ()

    gboolean
    camel_utils_sanitize_ascii_domain_in_url
                                   (CamelURL *url);

Checks whether the host name of the `url` requires conversion to ASCII and converts it, if needed.

#### Parameters

url | a CamelURL |

#### Returns

`TRUE`, when the conversion was required.

See: `camel_hostname_utils_requires_ascii()`, `camel_utils_sanitize_ascii_domain_in_url_str()`

Since: 3.44

## Types and Values

### socklen_t

    #define socklen_t int

### struct addrinfo

    struct addrinfo {
    	gint ai_flags;
    	gint ai_family;
    	gint ai_socktype;
    	gint ai_protocol;
    	gsize ai_addrlen;
    	struct sockaddr *ai_addr;
    	gchar *ai_canonname;
    	struct addrinfo *ai_next;
    };

### AI_CANONNAME

    #define AI_CANONNAME 0x0002 /* Request for canonical name.  */

### AI_NUMERICHOST

    #define AI_NUMERICHOST 0x0004 /* Don't use name resolution.  */

### EAI_BADFLAGS

    #define EAI_BADFLAGS	  -1 /* Invalid value for `ai_flags' field.  */

### EAI_NONAME

    #define EAI_NONAME	  -2 /* NAME or SERVICE is unknown.  */

### EAI_AGAIN

    #define EAI_AGAIN	  -3 /* Temporary failure in name resolution.  */

### EAI_FAIL

    #define EAI_FAIL	  -4 /* Non-recoverable failure in name res.  */

### EAI_NODATA

    #define EAI_NODATA	  -5 /* No address associated with NAME.  */

### EAI_FAMILY

    #define EAI_FAMILY	  -6 /* `ai_family' not supported.  */

### EAI_SOCKTYPE

    #define EAI_SOCKTYPE	  -7 /* `ai_socktype' not supported.  */

### EAI_SERVICE

    #define EAI_SERVICE	  -8 /* SERVICE not supported for `ai_socktype'.  */

### EAI_ADDRFAMILY

    #define EAI_ADDRFAMILY	  -9 /* Address family for NAME not supported.  */

### EAI_MEMORY

    #define EAI_MEMORY	  -10 /* Memory allocation failure.  */

### EAI_SYSTEM

    #define EAI_SYSTEM	  -11 /* System error returned in `errno'.  */

### EAI_OVERFLOW

    #define EAI_OVERFLOW	  -12 /* Argument buffer overflow.  */

### NI_NUMERICHOST

    #define NI_NUMERICHOST 1	/* Don't try to look up hostname.  */

### NI_NUMERICSERV

    #define NI_NUMERICSERV 2	/* Don't convert port number to name.  */

### NI_NOFQDN

    #define NI_NOFQDN 4	/* Only return nodename portion.  */

### NI_NAMEREQD

    #define NI_NAMEREQD 8	/* Don't return numeric addresses.  */

### NI_DGRAM

    #define NI_DGRAM 16 /* Look up UDP service rather than TCP.  */

### struct sockaddr

    struct sockaddr;