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.15"
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_profile stringprep_plain[];
00149 extern IDNAPI const Stringprep_profile stringprep_trace[];
00150
00151 # define stringprep_plain(in, maxlen) \
00152 stringprep(in, maxlen, 0, stringprep_plain)
00153
00154
00155
00156 extern IDNAPI const Stringprep_profile stringprep_kerberos5[];
00157
00158 # define stringprep_kerberos5(in, maxlen) \
00159 stringprep(in, maxlen, 0, stringprep_kerberos5)
00160
00161
00162
00163 extern IDNAPI const Stringprep_profile stringprep_xmpp_nodeprep[];
00164 extern IDNAPI const Stringprep_profile stringprep_xmpp_resourceprep[];
00165 extern IDNAPI const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[];
00166
00167 # define stringprep_xmpp_nodeprep(in, maxlen) \
00168 stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep)
00169 # define stringprep_xmpp_resourceprep(in, maxlen) \
00170 stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep)
00171
00172
00173
00174 extern IDNAPI const Stringprep_profile stringprep_iscsi[];
00175
00176 # define stringprep_iscsi(in, maxlen) \
00177 stringprep(in, maxlen, 0, stringprep_iscsi)
00178
00179
00180
00181 extern IDNAPI int stringprep_4i (uint32_t * ucs4, size_t * len,
00182 size_t maxucs4len,
00183 Stringprep_profile_flags flags,
00184 const Stringprep_profile * profile);
00185 extern IDNAPI int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
00186 Stringprep_profile_flags flags,
00187 const Stringprep_profile * profile);
00188 extern IDNAPI int stringprep (char *in, size_t maxlen,
00189 Stringprep_profile_flags flags,
00190 const Stringprep_profile * profile);
00191
00192 extern IDNAPI int stringprep_profile (const char *in,
00193 char **out,
00194 const char *profile,
00195 Stringprep_profile_flags flags);
00196
00197 extern IDNAPI const char *stringprep_strerror (Stringprep_rc rc);
00198
00199 extern IDNAPI const char *stringprep_check_version (const char
00200 *req_version);
00201
00202
00203
00204 extern IDNAPI int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf);
00205 extern IDNAPI uint32_t stringprep_utf8_to_unichar (const char *p);
00206
00207 extern IDNAPI uint32_t *stringprep_utf8_to_ucs4 (const char *str,
00208 ssize_t len,
00209 size_t * items_written);
00210 extern IDNAPI char *stringprep_ucs4_to_utf8 (const uint32_t * str,
00211 ssize_t len,
00212 size_t * items_read,
00213 size_t * items_written);
00214
00215 extern IDNAPI char *stringprep_utf8_nfkc_normalize (const char *str,
00216 ssize_t len);
00217 extern IDNAPI uint32_t *stringprep_ucs4_nfkc_normalize (uint32_t * str,
00218 ssize_t len);
00219
00220 extern IDNAPI const char *stringprep_locale_charset (void);
00221 extern IDNAPI char *stringprep_convert (const char *str,
00222 const char *to_codeset,
00223 const char *from_codeset);
00224 extern IDNAPI char *stringprep_locale_to_utf8 (const char *str);
00225 extern IDNAPI char *stringprep_utf8_to_locale (const char *str);
00226
00227 # ifdef __cplusplus
00228 }
00229 # endif
00230
00231 #endif