libidn  1.42
Macros | Functions | Variables
tld.c File Reference
#include <config.h>
#include <stringprep.h>
#include <string.h>
#include <tld.h>

Go to the source code of this file.

Macros

#define DOTP(c)
 

Functions

const Tld_tabletld_get_table (const char *tld, const Tld_table **tables)
 
const Tld_tabletld_default_table (const char *tld, const Tld_table **overrides)
 
int tld_get_4 (const uint32_t *in, size_t inlen, char **out)
 
int tld_get_4z (const uint32_t *in, char **out)
 
int tld_get_z (const char *in, char **out)
 
int tld_check_4t (const uint32_t *in, size_t inlen, size_t *errpos, const Tld_table *tld)
 
int tld_check_4tz (const uint32_t *in, size_t *errpos, const Tld_table *tld)
 
int tld_check_4 (const uint32_t *in, size_t inlen, size_t *errpos, const Tld_table **overrides)
 
int tld_check_4z (const uint32_t *in, size_t *errpos, const Tld_table **overrides)
 
int tld_check_8z (const char *in, size_t *errpos, const Tld_table **overrides)
 
int tld_check_lz (const char *in, size_t *errpos, const Tld_table **overrides)
 

Variables

const Tld_table_tld_tables []
 

Macro Definition Documentation

◆ DOTP

#define DOTP (   c)
Value:
((c) == 0x002E || (c) == 0x3002 || \
(c) == 0xFF0E || (c) == 0xFF61)

Definition at line 105 of file tld.c.

Function Documentation

◆ tld_check_4()

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

tld_check_4:

Parameters
inArray of unicode code points to process. Does not need to be zero terminated.
inlenNumber of unicode code points.
errposPosition of offending character is returned here.
overridesA 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()

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

tld_check_4t:

Parameters
inArray of unicode code points to process. Does not need to be zero terminated.
inlenNumber of unicode code points.
errposPosition of offending character is returned here.
tldA 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()

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

tld_check_4tz:

Parameters
inZero terminated array of unicode code points to process.
errposPosition of offending character is returned here.
tldA 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()

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

tld_check_4z:

Parameters
inZero-terminated array of unicode code points to process.
errposPosition of offending character is returned here.
overridesA 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()

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

tld_check_8z:

Parameters
inZero-terminated UTF8 string to process.
errposPosition of offending character is returned here.
overridesA 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()

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

tld_check_lz:

Parameters
inZero-terminated string in the current locales encoding to process.
errposPosition of offending character is returned here.
overridesA 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()

const Tld_table* tld_default_table ( const char *  tld,
const Tld_table **  overrides 
)

tld_default_table:

Parameters
tldTLD name (e.g. "com") as zero terminated ASCII byte string.
overridesAdditional 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()

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

tld_get_4:

Parameters
inArray of unicode code points to process. Does not need to be zero terminated.
inlenNumber of unicode code points.
outZero 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()

int tld_get_4z ( const uint32_t *  in,
char **  out 
)

tld_get_4z:

Parameters
inZero terminated array of unicode code points to process.
outZero 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()

const Tld_table* tld_get_table ( const char *  tld,
const Tld_table **  tables 
)

tld_get_table:

Parameters
tldTLD name (e.g. "com") as zero terminated ASCII byte string.
tablesZero 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()

int tld_get_z ( const char *  in,
char **  out 
)

tld_get_z:

Parameters
inZero terminated character array to process.
outZero 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.

Variable Documentation

◆ _tld_tables

const Tld_table* _tld_tables[]
extern

Definition at line 60 of file tlds.c.