libidn 1.43

Data Structures | Macros | Typedefs | Enumerations | Functions
tld.h File Reference
`#include <stdlib.h>`
`#include <idn-int.h>`

Go to the source code of this file.

## Data Structures
struct | Tld_table_element
struct | Tld_table

## Macros
#define | IDNAPI

## Typedefs
typedef struct Tld_table_element | Tld_table_element
typedef struct Tld_table | Tld_table

## Enumerations
enum | Tld_rc { TLD_SUCCESS = 0 , TLD_INVALID = 1 , TLD_NODATA = 2 , TLD_MALLOC_ERROR = 3 , TLD_ICONV_ERROR = 4 , TLD_NO_TLD = 5 , TLD_NOTLD = TLD_NO_TLD }

## Functions
IDNAPI const char * | tld_strerror (Tld_rc rc)
IDNAPI int | tld_get_4 (const uint32_t *in, size_t inlen, char **out)
IDNAPI int | tld_get_4z (const uint32_t *in, char **out)
IDNAPI int | tld_get_z (const char *in, char **out)
IDNAPI const Tld_table * | tld_get_table (const char *tld, const Tld_table **tables)
IDNAPI const Tld_table * | tld_default_table (const char *tld, const Tld_table **overrides)
IDNAPI int | tld_check_4t (const uint32_t *in, size_t inlen, size_t *errpos, const Tld_table *tld)
IDNAPI int | tld_check_4tz (const uint32_t *in, size_t *errpos, const Tld_table *tld)
IDNAPI int | tld_check_4 (const uint32_t *in, size_t inlen, size_t *errpos, const Tld_table **overrides)
IDNAPI int | tld_check_4z (const uint32_t *in, size_t *errpos, const Tld_table **overrides)
IDNAPI int | tld_check_8z (const char *in, size_t *errpos, const Tld_table **overrides)
IDNAPI int | tld_check_lz (const char *in, size_t *errpos, const Tld_table **overrides)

## Macro Definition Documentation

## ◆ IDNAPI

#define IDNAPI

SECTION:tld

Parameters

  title | tld.h
  short_description | TLD-related functions

TLD-related functions.

Definition at line 52 of file tld.h.

## Typedef Documentation

## ◆ Tld_table

typedef struct Tld_table Tld_table

Definition at line 101 of file tld.h.

## ◆ Tld_table_element

typedef struct Tld_table_element Tld_table_element

Definition at line 83 of file tld.h.

## Enumeration Type Documentation

## ◆ Tld_rc

enum Tld_rc

Enumerator
TLD_SUCCESS |
TLD_INVALID |
TLD_NODATA |
TLD_MALLOC_ERROR |
TLD_ICONV_ERROR |
TLD_NO_TLD |
TLD_NOTLD |

Definition at line 105 of file tld.h.

## Function Documentation

## ◆ tld_check_4()

IDNAPI int tld_check_4 | ( | const uint32_t * | in,
|  | size_t | inlen,
|  | size_t * | errpos,
|  | const Tld_table ** | overrides )
| extern

tld_check_4:

Parameters

  in | Array of unicode code points to process. Does not need to be zero terminated.
  inlen | Number of unicode code points.
  errpos | Position of offending character is returned here.
  overrides | A Tld_table array of additional domain restriction structures that complement and supersede the built-in information.

Test each of the code points in @in for whether or not they are allowed by the information in @overrides or by the built-in TLD restriction data. When data for the same TLD is available both internally and in @overrides, the information in @overrides takes precedence. If several entries for a specific TLD are found, the first one is used. If @overrides is NULL, only the built-in information is used. The position of the first offending character is returned in @errpos.

Return value: Returns the Tld_rc value TLD_SUCCESS if all code points are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 359 of file tld.c.

## ◆ tld_check_4t()

IDNAPI int tld_check_4t | ( | const uint32_t * | in,
|  | size_t | inlen,
|  | size_t * | errpos,
|  | const Tld_table * | tld )
| extern

tld_check_4t:

Parameters

  in | Array of unicode code points to process. Does not need to be zero terminated.
  inlen | Number of unicode code points.
  errpos | Position of offending character is returned here.
  tld | A Tld_table data structure representing the restrictions for which the input should be tested.

Test each of the code points in @in for whether or not they are allowed by the data structure in @tld, return the position of the first character for which this is not the case in @errpos.

Return value: Returns the Tld_rc value TLD_SUCCESS if all code points are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 280 of file tld.c.

## ◆ tld_check_4tz()

IDNAPI int tld_check_4tz | ( | const uint32_t * | in,
|  | size_t * | errpos,
|  | const Tld_table * | tld )
| extern

tld_check_4tz:

Parameters

  in | Zero terminated array of unicode code points to process.
  errpos | Position of offending character is returned here.
  tld | A Tld_table data structure representing the restrictions for which the input should be tested.

Test each of the code points in @in for whether or not they are allowed by the data structure in @tld, return the position of the first character for which this is not the case in @errpos.

Return value: Returns the Tld_rc value TLD_SUCCESS if all code points are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 322 of file tld.c.

## ◆ tld_check_4z()

IDNAPI int tld_check_4z | ( | const uint32_t * | in,
|  | size_t * | errpos,
|  | const Tld_table ** | overrides )
| extern

tld_check_4z:

Parameters

  in | Zero-terminated array of unicode code points to process.
  errpos | Position of offending character is returned here.
  overrides | A Tld_table array of additional domain restriction structures that complement and supersede the built-in information.

Test each of the code points in @in for whether or not they are allowed by the information in @overrides or by the built-in TLD restriction data. When data for the same TLD is available both internally and in @overrides, the information in @overrides takes precedence. If several entries for a specific TLD are found, the first one is used. If @overrides is NULL, only the built-in information is used. The position of the first offending character is returned in @errpos.

Return value: Returns the Tld_rc value TLD_SUCCESS if all code points are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 409 of file tld.c.

## ◆ tld_check_8z()

IDNAPI int tld_check_8z | ( | const char * | in,
|  | size_t * | errpos,
|  | const Tld_table ** | overrides )
| extern

tld_check_8z:

Parameters

  in | Zero-terminated UTF8 string to process.
  errpos | Position of offending character is returned here.
  overrides | A Tld_table array of additional domain restriction structures that complement and supersede the built-in information.

Test each of the characters in @in for whether or not they are allowed by the information in @overrides or by the built-in TLD restriction data. When data for the same TLD is available both internally and in @overrides, the information in @overrides takes precedence. If several entries for a specific TLD are found, the first one is used. If @overrides is NULL, only the built-in information is used. The position of the first offending character is returned in @errpos. Note that the error position refers to the decoded character offset rather than the byte position in the string.

Return value: Returns the Tld_rc value TLD_SUCCESS if all characters are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 446 of file tld.c.

## ◆ tld_check_lz()

IDNAPI int tld_check_lz | ( | const char * | in,
|  | size_t * | errpos,
|  | const Tld_table ** | overrides )
| extern

tld_check_lz:

Parameters

  in | Zero-terminated string in the current locales encoding to process.
  errpos | Position of offending character is returned here.
  overrides | A Tld_table array of additional domain restriction structures that complement and supersede the built-in information.

Test each of the characters in @in for whether or not they are allowed by the information in @overrides or by the built-in TLD restriction data. When data for the same TLD is available both internally and in @overrides, the information in @overrides takes precedence. If several entries for a specific TLD are found, the first one is used. If @overrides is NULL, only the built-in information is used. The position of the first offending character is returned in @errpos. Note that the error position refers to the decoded character offset rather than the byte position in the string.

Return value: Returns the Tld_rc value TLD_SUCCESS if all characters are valid or when @tld is null, TLD_INVALID if a character is not allowed, or additional error codes on general failure conditions.

Definition at line 491 of file tld.c.

## ◆ tld_default_table()

IDNAPI const Tld_table * tld_default_table | ( | const char * | tld,
|  | const Tld_table ** | overrides )
| extern

tld_default_table:

Parameters

  tld | TLD name (e.g. "com") as zero terminated ASCII byte string.
  overrides | Additional zero terminated array of Tld_table info-structures for TLDs, or NULL to only use library default tables.

Get the TLD table for a named TLD, using the internal defaults, possibly overridden by the (optional) supplied tables.

Return value: Return structure corresponding to TLD @tld_str, first looking through @overrides then thru built-in list, or NULL if no such structure found.

Definition at line 89 of file tld.c.

## ◆ tld_get_4()

IDNAPI int tld_get_4 | ( | const uint32_t * | in,
|  | size_t | inlen,
|  | char ** | out )
| extern

tld_get_4:

Parameters

  in | Array of unicode code points to process. Does not need to be zero terminated.
  inlen | Number of unicode code points.
  out | Zero terminated ascii result string pointer.

Isolate the top-level domain of @in and return it as an ASCII string in @out.

Return value: Return TLD_SUCCESS on success, or the corresponding Tld_rc error code otherwise.

Definition at line 122 of file tld.c.

## ◆ tld_get_4z()

IDNAPI int tld_get_4z | ( | const uint32_t * | in,
|  | char ** | out )
| extern

tld_get_4z:

Parameters

  in | Zero terminated array of unicode code points to process.
  out | Zero terminated ascii result string pointer.

Isolate the top-level domain of @in and return it as an ASCII string in @out.

Return value: Return TLD_SUCCESS on success, or the corresponding Tld_rc error code otherwise.

Definition at line 171 of file tld.c.

## ◆ tld_get_table()

IDNAPI const Tld_table * tld_get_table | ( | const char * | tld,
|  | const Tld_table ** | tables )
| extern

tld_get_table:

Parameters

  tld | TLD name (e.g. "com") as zero terminated ASCII byte string.
  tables | Zero terminated array of Tld_table info-structures for TLDs.

Get the TLD table for a named TLD by searching through the given TLD table array.

Return value: Return structure corresponding to TLD @tld by going thru @tables, or return NULL if no such structure is found.

Definition at line 60 of file tld.c.

## ◆ tld_get_z()

IDNAPI int tld_get_z | ( | const char * | in,
|  | char ** | out )
| extern

tld_get_z:

Parameters

  in | Zero terminated character array to process.
  out | Zero terminated ascii result string pointer.

Isolate the top-level domain of @in and return it as an ASCII string in @out. The input string @in may be UTF-8, ISO-8859-1 or any ASCII compatible character encoding.

Return value: Return TLD_SUCCESS on success, or the corresponding Tld_rc error code otherwise.

Definition at line 197 of file tld.c.

## ◆ tld_strerror()

IDNAPI const char * tld_strerror | ( | Tld_rc | rc | ) |
| extern

tld_strerror:

Parameters

  rc | tld return code

Convert a return code integer to a text string. This string can be used to output a diagnostic message to the user.

TLD_SUCCESS: Successful operation. This value is guaranteed to always be zero, the remaining ones are only guaranteed to hold non-zero values, for logical comparison purposes. TLD_INVALID: Invalid character found. TLD_NODATA: No input data was provided. TLD_MALLOC_ERROR: Error during memory allocation. TLD_ICONV_ERROR: Character encoding conversion error. TLD_NO_TLD: No top-level domain found in domain string.

Return value: Returns a pointer to a statically allocated string containing a description of the error with the return code @rc.

Definition at line 59 of file strerror-tld.c.