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