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