00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef TLD_H
00026 # define TLD_H
00027
00028 # ifndef IDNAPI
00029 # if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
00030 # define IDNAPI __attribute__((__visibility__("default")))
00031 # elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
00032 # define IDNAPI __declspec(dllexport)
00033 # elif defined _MSC_VER && ! defined LIBIDN_STATIC
00034 # define IDNAPI __declspec(dllimport)
00035 # else
00036 # define IDNAPI
00037 # endif
00038 # endif
00039
00040 # ifdef __cplusplus
00041 extern "C"
00042 {
00043 # endif
00044
00045
00046 # include <stdlib.h>
00047
00048
00049 # include <idn-int.h>
00050
00051
00052 struct Tld_table_element
00053 {
00054 uint32_t start;
00055 uint32_t end;
00056 };
00057 typedef struct Tld_table_element Tld_table_element;
00058
00059
00060 struct Tld_table
00061 {
00062 const char *name;
00063 const char *version;
00064 size_t nvalid;
00065 const Tld_table_element *valid;
00066 };
00067 typedef struct Tld_table Tld_table;
00068
00069
00070 typedef enum
00071 {
00072 TLD_SUCCESS = 0,
00073 TLD_INVALID = 1,
00074 TLD_NODATA = 2,
00075 TLD_MALLOC_ERROR = 3,
00076 TLD_ICONV_ERROR = 4,
00077 TLD_NO_TLD = 5,
00078
00079 TLD_NOTLD = TLD_NO_TLD
00080 } Tld_rc;
00081
00082 extern IDNAPI const char *tld_strerror (Tld_rc rc);
00083
00084
00085 extern IDNAPI int tld_get_4 (const uint32_t * in, size_t inlen,
00086 char **out);
00087 extern IDNAPI int tld_get_4z (const uint32_t * in, char **out);
00088 extern IDNAPI int tld_get_z (const char *in, char **out);
00089
00090
00091
00092
00093 extern IDNAPI const Tld_table *tld_get_table (const char *tld,
00094 const Tld_table ** tables);
00095
00096
00097
00098
00099 extern IDNAPI const Tld_table * tld_default_table (const char *tld,
00100 const Tld_table ** overrides);
00101
00102
00103
00104
00105 extern IDNAPI int tld_check_4t (const uint32_t * in, size_t inlen,
00106 size_t * errpos, const Tld_table * tld);
00107 extern IDNAPI int tld_check_4tz (const uint32_t * in, size_t * errpos,
00108 const Tld_table * tld);
00109
00110
00111
00112
00113 extern IDNAPI int tld_check_4 (const uint32_t * in, size_t inlen,
00114 size_t * errpos,
00115 const Tld_table ** overrides);
00116 extern IDNAPI int tld_check_4z (const uint32_t * in, size_t * errpos,
00117 const Tld_table ** overrides);
00118 extern IDNAPI int tld_check_8z (const char *in, size_t * errpos,
00119 const Tld_table ** overrides);
00120 extern IDNAPI int tld_check_lz (const char *in, size_t * errpos,
00121 const Tld_table ** overrides);
00122
00123 # ifdef __cplusplus
00124 }
00125 # endif
00126
00127 #endif