00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef STRINGPREP_H
00023 # define STRINGPREP_H
00024
00025 # ifndef IDNAPI
00026 # if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
00027 # define IDNAPI __attribute__((__visibility__("default")))
00028 # elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
00029 # define IDNAPI __declspec(dllexport)
00030 # elif defined _MSC_VER && ! defined LIBIDN_STATIC
00031 # define IDNAPI __declspec(dllimport)
00032 # else
00033 # define IDNAPI
00034 # endif
00035 # endif
00036
00037 # include <stddef.h>
00038 # include <unistd.h>
00039 # include <idn-int.h>
00040
00041 # ifdef __cplusplus
00042 extern "C"
00043 {
00044 # endif
00045
00046 # define STRINGPREP_VERSION "1.18"
00047
00048
00049 typedef enum
00050 {
00051 STRINGPREP_OK = 0,
00052
00053 STRINGPREP_CONTAINS_UNASSIGNED = 1,
00054 STRINGPREP_CONTAINS_PROHIBITED = 2,
00055 STRINGPREP_BIDI_BOTH_L_AND_RAL = 3,
00056 STRINGPREP_BIDI_LEADTRAIL_NOT_RAL = 4,
00057 STRINGPREP_BIDI_CONTAINS_PROHIBITED = 5,
00058
00059 STRINGPREP_TOO_SMALL_BUFFER = 100,
00060 STRINGPREP_PROFILE_ERROR = 101,
00061 STRINGPREP_FLAG_ERROR = 102,
00062 STRINGPREP_UNKNOWN_PROFILE = 103,
00063
00064 STRINGPREP_NFKC_FAILED = 200,
00065 STRINGPREP_MALLOC_ERROR = 201
00066 } Stringprep_rc;
00067
00068
00069 typedef enum
00070 {
00071 STRINGPREP_NO_NFKC = 1,
00072 STRINGPREP_NO_BIDI = 2,
00073 STRINGPREP_NO_UNASSIGNED = 4
00074 } Stringprep_profile_flags;
00075
00076
00077 typedef enum
00078 {
00079 STRINGPREP_NFKC = 1,
00080 STRINGPREP_BIDI = 2,
00081 STRINGPREP_MAP_TABLE = 3,
00082 STRINGPREP_UNASSIGNED_TABLE = 4,
00083 STRINGPREP_PROHIBIT_TABLE = 5,
00084 STRINGPREP_BIDI_PROHIBIT_TABLE = 6,
00085 STRINGPREP_BIDI_RAL_TABLE = 7,
00086 STRINGPREP_BIDI_L_TABLE = 8
00087 } Stringprep_profile_steps;
00088
00089 # define STRINGPREP_MAX_MAP_CHARS 4
00090
00091 struct Stringprep_table_element
00092 {
00093 uint32_t start;
00094 uint32_t end;
00095 uint32_t map[STRINGPREP_MAX_MAP_CHARS];
00096 };
00097 typedef struct Stringprep_table_element Stringprep_table_element;
00098
00099 struct Stringprep_table
00100 {
00101 Stringprep_profile_steps operation;
00102 Stringprep_profile_flags flags;
00103 const Stringprep_table_element *table;
00104 };
00105 typedef struct Stringprep_table Stringprep_profile;
00106
00107 struct Stringprep_profiles
00108 {
00109 const char *name;
00110 const Stringprep_profile *tables;
00111 };
00112 typedef struct Stringprep_profiles Stringprep_profiles;
00113
00114 extern IDNAPI const Stringprep_profiles stringprep_profiles[];
00115
00116
00117 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_A_1[];
00118 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_1[];
00119 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_2[];
00120 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_3[];
00121 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_1_1[];
00122 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_1_2[];
00123 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_2_1[];
00124 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_2_2[];
00125 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_3[];
00126 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_4[];
00127 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_5[];
00128 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_6[];
00129 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_7[];
00130 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_8[];
00131 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_9[];
00132 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_D_1[];
00133 extern IDNAPI const Stringprep_table_element stringprep_rfc3454_D_2[];
00134
00135
00136
00137 extern IDNAPI const Stringprep_profile stringprep_nameprep[];
00138
00139 # define stringprep_nameprep(in, maxlen) \
00140 stringprep(in, maxlen, 0, stringprep_nameprep)
00141
00142 # define stringprep_nameprep_no_unassigned(in, maxlen) \
00143 stringprep(in, maxlen, STRINGPREP_NO_UNASSIGNED, stringprep_nameprep)
00144
00145
00146
00147 extern IDNAPI const Stringprep_profile stringprep_saslprep[];
00148 extern IDNAPI const Stringprep_table_element stringprep_saslprep_space_map[];
00149 extern IDNAPI const Stringprep_profile stringprep_plain[];
00150 extern IDNAPI const Stringprep_profile stringprep_trace[];
00151
00152 # define stringprep_plain(in, maxlen) \
00153 stringprep(in, maxlen, 0, stringprep_plain)
00154
00155
00156
00157 extern IDNAPI const Stringprep_profile stringprep_kerberos5[];
00158
00159 # define stringprep_kerberos5(in, maxlen) \
00160 stringprep(in, maxlen, 0, stringprep_kerberos5)
00161
00162
00163
00164 extern IDNAPI const Stringprep_profile stringprep_xmpp_nodeprep[];
00165 extern IDNAPI const Stringprep_profile stringprep_xmpp_resourceprep[];
00166 extern IDNAPI const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[];
00167
00168 # define stringprep_xmpp_nodeprep(in, maxlen) \
00169 stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep)
00170 # define stringprep_xmpp_resourceprep(in, maxlen) \
00171 stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep)
00172
00173
00174
00175 extern IDNAPI const Stringprep_profile stringprep_iscsi[];
00176 extern IDNAPI const Stringprep_table_element stringprep_iscsi_prohibit[];
00177
00178 # define stringprep_iscsi(in, maxlen) \
00179 stringprep(in, maxlen, 0, stringprep_iscsi)
00180
00181
00182
00183 extern IDNAPI int stringprep_4i (uint32_t * ucs4, size_t * len,
00184 size_t maxucs4len,
00185 Stringprep_profile_flags flags,
00186 const Stringprep_profile * profile);
00187 extern IDNAPI int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
00188 Stringprep_profile_flags flags,
00189 const Stringprep_profile * profile);
00190 extern IDNAPI int stringprep (char *in, size_t maxlen,
00191 Stringprep_profile_flags flags,
00192 const Stringprep_profile * profile);
00193
00194 extern IDNAPI int stringprep_profile (const char *in,
00195 char **out,
00196 const char *profile,
00197 Stringprep_profile_flags flags);
00198
00199 extern IDNAPI const char *stringprep_strerror (Stringprep_rc rc);
00200
00201 extern IDNAPI const char *stringprep_check_version (const char
00202 *req_version);
00203
00204
00205
00206 extern IDNAPI int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf);
00207 extern IDNAPI uint32_t stringprep_utf8_to_unichar (const char *p);
00208
00209 extern IDNAPI uint32_t *stringprep_utf8_to_ucs4 (const char *str,
00210 ssize_t len,
00211 size_t * items_written);
00212 extern IDNAPI char *stringprep_ucs4_to_utf8 (const uint32_t * str,
00213 ssize_t len,
00214 size_t * items_read,
00215 size_t * items_written);
00216
00217 extern IDNAPI char *stringprep_utf8_nfkc_normalize (const char *str,
00218 ssize_t len);
00219 extern IDNAPI uint32_t *stringprep_ucs4_nfkc_normalize (uint32_t * str,
00220 ssize_t len);
00221
00222 extern IDNAPI const char *stringprep_locale_charset (void);
00223 extern IDNAPI char *stringprep_convert (const char *str,
00224 const char *to_codeset,
00225 const char *from_codeset);
00226 extern IDNAPI char *stringprep_locale_to_utf8 (const char *str);
00227 extern IDNAPI char *stringprep_utf8_to_locale (const char *str);
00228
00229 # ifdef __cplusplus
00230 }
00231 # endif
00232
00233 #endif