Next: PR29 Functions, Previous: IDNA Functions, Up: Top
Organizations that manage some Top Level Domains (TLDs) have published tables with characters they accept within the domain. The reason may be to reduce complexity that come from using the full Unicode range, and to protect themselves from future (backwards incompatible) changes in the IDN or Unicode specifications. Libidn implement an infrastructure for defining and checking strings against such tables. Libidn also ship some tables from TLDs that we have managed to get permission to use them from. Because these tables are even less static than Unicode or StringPrep tables, it is likely that they will be updated from time to time (even in backwards incompatibe ways). The Libidn interface provide a “version” field for each TLD table, which can be compared for equality to guarantee the same operation over time.
From a design point of view, you can regard the TLD tables for IDN as the “localization” step that come after the “internationalization” step provided by the IETF standards.
The TLD functionality rely on up-to-date tables. The latest version of Libidn aim to provide these, but tables with unclear copying conditions, or generally experimental tables, are not included. Some such tables can be found at http://tldchk.berlios.de.
tld.hTo use the functions explained in this chapter, you need to include the file tld.h using:
#include <tld.h>
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_tabledata structure representing the restrictions for which the input should be tested.Test each of the code points in
infor whether or not they are allowed by the data structure intld, return the position of the first character for which this is not the case inerrpos.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all code points are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
in: Zero terminated array of unicode code points to process.
errpos: Position of offending character is returned here.
tld: A
Tld_tabledata structure representing the restrictions for which the input should be tested.Test each of the code points in
infor whether or not they are allowed by the data structure intld, return the position of the first character for which this is not the case inerrpos.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all code points are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
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
inand return it as an ASCII string inout.Return value: Return
TLD_SUCCESSon success, or the correspondingTld_rcerror code otherwise.
in: Zero terminated array of unicode code points to process.
out: Zero terminated ascii result string pointer.
Isolate the top-level domain of
inand return it as an ASCII string inout.Return value: Return
TLD_SUCCESSon success, or the correspondingTld_rcerror code otherwise.
in: Zero terminated character array to process.
out: Zero terminated ascii result string pointer.
Isolate the top-level domain of
inand return it as an ASCII string inout. The input stringinmay be UTF-8, ISO-8859-1 or any ASCII compatible character encoding.Return value: Return
TLD_SUCCESSon success, or the correspondingTld_rcerror code otherwise.
tld: TLD name (e.g. "com") as zero terminated ASCII byte string.
tables: Zero terminated array of
Tld_tableinfo-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
tldby going thrutables, or returnNULLif no such structure is found.
tld: TLD name (e.g. "com") as zero terminated ASCII byte string.
overrides: Additional zero terminated array of
Tld_tableinfo-structures for TLDs, orNULLto only use library deault tables.Get the TLD table for a named TLD, using the internal defaults, possibly overrided by the (optional) supplied tables.
Return value: Return structure corresponding to TLD
tld_str, first looking throughoverridesthen thru built-in list, orNULLif no such structure found.
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_tablearray of additional domain restriction structures that complement and supersede the built-in information.Test each of the code points in
infor whether or not they are allowed by the information inoverridesor by the built-in TLD restriction data. When data for the same TLD is available both internally and inoverrides, the information inoverridestakes precedence. If several entries for a specific TLD are found, the first one is used. IfoverridesisNULL, only the built-in information is used. The position of the first offending character is returned inerrpos.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all code points are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
in: Zero-terminated array of unicode code points to process.
errpos: Position of offending character is returned here.
overrides: A
Tld_tablearray of additional domain restriction structures that complement and supersede the built-in information.Test each of the code points in
infor whether or not they are allowed by the information inoverridesor by the built-in TLD restriction data. When data for the same TLD is available both internally and inoverrides, the information inoverridestakes precedence. If several entries for a specific TLD are found, the first one is used. IfoverridesisNULL, only the built-in information is used. The position of the first offending character is returned inerrpos.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all code points are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
in: Zero-terminated UTF8 string to process.
errpos: Position of offending character is returned here.
overrides: A
Tld_tablearray of additional domain restriction structures that complement and supersede the built-in information.Test each of the characters in
infor whether or not they are allowed by the information inoverridesor by the built-in TLD restriction data. When data for the same TLD is available both internally and inoverrides, the information inoverridestakes precedence. If several entries for a specific TLD are found, the first one is used. IfoverridesisNULL, only the built-in information is used. The position of the first offending character is returned inerrpos. Note that the error position refers to the decoded character offset rather than the byte position in the string.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all characters are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
in: Zero-terminated string in the current locales encoding to process.
errpos: Position of offending character is returned here.
overrides: A
Tld_tablearray of additional domain restriction structures that complement and supersede the built-in information.Test each of the characters in
infor whether or not they are allowed by the information inoverridesor by the built-in TLD restriction data. When data for the same TLD is available both internally and inoverrides, the information inoverridestakes precedence. If several entries for a specific TLD are found, the first one is used. IfoverridesisNULL, only the built-in information is used. The position of the first offending character is returned inerrpos. Note that the error position refers to the decoded character offset rather than the byte position in the string.Return value: Returns the
Tld_rcvalueTLD_SUCCESSif all characters are valid or whentldis null,TLD_INVALIDif a character is not allowed, or additional error codes on general failure conditions.
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: Error during iconv string conversion.
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.