File indexing completed on 2025-01-17 09:55:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef IDN2_H
0030 # define IDN2_H
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #ifndef _IDN2_API
0043 # if defined IDN2_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
0044 # define _IDN2_API __attribute__((__visibility__("default")))
0045 # elif defined IDN2_BUILDING && defined _MSC_VER && ! defined IDN2_STATIC
0046 # define _IDN2_API __declspec(dllexport)
0047 # elif defined _MSC_VER && ! defined IDN2_STATIC
0048 # define _IDN2_API __declspec(dllimport)
0049 # else
0050 # define _IDN2_API
0051 # endif
0052 #endif
0053
0054
0055 # include <stdint.h> /* uint32_t */
0056 # include <string.h> /* size_t */
0057
0058 # ifdef __cplusplus
0059 extern "C"
0060 {
0061 # endif
0062
0063
0064
0065
0066
0067
0068
0069
0070 # if defined __GNUC__ && defined __GNUC_MINOR__
0071 # define GCC_VERSION_AT_LEAST(major, minor) ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
0072 # else
0073 # define GCC_VERSION_AT_LEAST(major, minor) 0
0074 # endif
0075
0076
0077
0078
0079
0080
0081
0082
0083 # if GCC_VERSION_AT_LEAST(2,96)
0084 # define G_GNUC_IDN2_ATTRIBUTE_PURE __attribute__ ((pure))
0085 # else
0086 # define G_GNUC_IDN2_ATTRIBUTE_PURE
0087 # endif
0088
0089
0090
0091
0092
0093
0094 # if GCC_VERSION_AT_LEAST(2,5)
0095 # define G_GNUC_IDN2_ATTRIBUTE_CONST __attribute__ ((const))
0096 # else
0097 # define G_GNUC_IDN2_ATTRIBUTE_CONST
0098 # endif
0099
0100
0101
0102
0103
0104
0105 # if GCC_VERSION_AT_LEAST(2,95)
0106 # define G_GNUC_UNUSED __attribute__ ((__unused__))
0107 # else
0108 # define G_GNUC_UNUSED
0109 # endif
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 # define IDN2_VERSION "2.3.7"
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 # define IDN2_VERSION_NUMBER 0x02030007
0131
0132
0133
0134
0135
0136
0137
0138 # define IDN2_VERSION_MAJOR 2
0139
0140
0141
0142
0143
0144
0145
0146 # define IDN2_VERSION_MINOR 3
0147
0148
0149
0150
0151
0152
0153
0154 # define IDN2_VERSION_PATCH 7
0155
0156
0157
0158
0159
0160
0161
0162 # define IDN2_LABEL_MAX_LENGTH 63
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 # define IDN2_DOMAIN_MAX_LENGTH 255
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 typedef enum
0192 {
0193 IDN2_NFC_INPUT = 1,
0194 IDN2_ALABEL_ROUNDTRIP = 2,
0195 IDN2_TRANSITIONAL = 4,
0196 IDN2_NONTRANSITIONAL = 8,
0197 IDN2_ALLOW_UNASSIGNED = 16,
0198 IDN2_USE_STD3_ASCII_RULES = 32,
0199 IDN2_NO_TR46 = 64,
0200 IDN2_NO_ALABEL_ROUNDTRIP = 128
0201 } idn2_flags;
0202
0203
0204
0205 extern _IDN2_API int
0206 idn2_lookup_u8 (const uint8_t * src, uint8_t ** lookupname, int flags);
0207
0208 extern _IDN2_API int
0209 idn2_register_u8 (const uint8_t * ulabel, const uint8_t * alabel,
0210 uint8_t ** insertname, int flags);
0211
0212
0213
0214 extern _IDN2_API int
0215 idn2_lookup_ul (const char *src, char **lookupname, int flags);
0216
0217 extern _IDN2_API int
0218 idn2_register_ul (const char *ulabel, const char *alabel,
0219 char **insertname, int flags);
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260 typedef enum
0261 {
0262 IDN2_OK = 0,
0263 IDN2_MALLOC = -100,
0264 IDN2_NO_CODESET = -101,
0265 IDN2_ICONV_FAIL = -102,
0266 IDN2_ENCODING_ERROR = -200,
0267 IDN2_NFC = -201,
0268 IDN2_PUNYCODE_BAD_INPUT = -202,
0269 IDN2_PUNYCODE_BIG_OUTPUT = -203,
0270 IDN2_PUNYCODE_OVERFLOW = -204,
0271 IDN2_TOO_BIG_DOMAIN = -205,
0272 IDN2_TOO_BIG_LABEL = -206,
0273 IDN2_INVALID_ALABEL = -207,
0274 IDN2_UALABEL_MISMATCH = -208,
0275 IDN2_INVALID_FLAGS = -209,
0276 IDN2_NOT_NFC = -300,
0277 IDN2_2HYPHEN = -301,
0278 IDN2_HYPHEN_STARTEND = -302,
0279 IDN2_LEADING_COMBINING = -303,
0280 IDN2_DISALLOWED = -304,
0281 IDN2_CONTEXTJ = -305,
0282 IDN2_CONTEXTJ_NO_RULE = -306,
0283 IDN2_CONTEXTO = -307,
0284 IDN2_CONTEXTO_NO_RULE = -308,
0285 IDN2_UNASSIGNED = -309,
0286 IDN2_BIDI = -310,
0287 IDN2_DOT_IN_LABEL = -311,
0288 IDN2_INVALID_TRANSITIONAL = -312,
0289 IDN2_INVALID_NONTRANSITIONAL = -313,
0290 IDN2_ALABEL_ROUNDTRIP_FAILED = -314,
0291 } idn2_rc;
0292
0293
0294
0295 extern _IDN2_API int idn2_to_ascii_4i (const uint32_t * input, size_t inlen,
0296 char *output, int flags);
0297 extern _IDN2_API int idn2_to_ascii_4i2 (const uint32_t * input,
0298 size_t inlen, char **output,
0299 int flags);
0300 extern _IDN2_API int idn2_to_ascii_4z (const uint32_t * input,
0301 char **output, int flags);
0302 extern _IDN2_API int idn2_to_ascii_8z (const char *input, char **output,
0303 int flags);
0304 extern _IDN2_API int idn2_to_ascii_lz (const char *input, char **output,
0305 int flags);
0306
0307 extern _IDN2_API int idn2_to_unicode_8z4z (const char *input,
0308 uint32_t ** output,
0309 int flags G_GNUC_UNUSED);
0310 extern _IDN2_API int idn2_to_unicode_4z4z (const uint32_t * input,
0311 uint32_t ** output, int flags);
0312 extern _IDN2_API int idn2_to_unicode_44i (const uint32_t * in, size_t inlen,
0313 uint32_t * out, size_t *outlen,
0314 int flags);
0315 extern _IDN2_API int idn2_to_unicode_8z8z (const char *input, char **output,
0316 int flags);
0317 extern _IDN2_API int idn2_to_unicode_8zlz (const char *input, char **output,
0318 int flags);
0319 extern _IDN2_API int idn2_to_unicode_lzlz (const char *input, char **output,
0320 int flags);
0321
0322 extern _IDN2_API int idn2_punycode_encode (const uint32_t * input,
0323 size_t input_length,
0324 char *output,
0325 size_t *output_length);
0326 extern _IDN2_API int idn2_punycode_decode (const char *input,
0327 size_t input_length,
0328 uint32_t * output,
0329 size_t *output_length);
0330
0331 extern _IDN2_API const char *idn2_strerror (int rc)
0332 G_GNUC_IDN2_ATTRIBUTE_CONST;
0333 extern _IDN2_API const char *idn2_strerror_name (int rc)
0334 G_GNUC_IDN2_ATTRIBUTE_CONST;
0335
0336 extern _IDN2_API const char *idn2_check_version (const char *req_version)
0337 G_GNUC_IDN2_ATTRIBUTE_PURE;
0338
0339 extern _IDN2_API void idn2_free (void *ptr);
0340
0341 # ifndef __GTK_DOC_IGNORE__
0342
0343 # if !defined IDNA_H && !defined IDN2_SKIP_LIBIDN_COMPAT
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366 typedef enum
0367 {
0368 IDNA_SUCCESS = IDN2_OK,
0369 IDNA_STRINGPREP_ERROR = IDN2_ENCODING_ERROR,
0370 IDNA_PUNYCODE_ERROR = IDN2_PUNYCODE_BAD_INPUT,
0371 IDNA_CONTAINS_NON_LDH = IDN2_ENCODING_ERROR,
0372 IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
0373 IDNA_CONTAINS_MINUS = IDN2_ENCODING_ERROR,
0374 IDNA_INVALID_LENGTH = IDN2_DISALLOWED,
0375 IDNA_NO_ACE_PREFIX = IDN2_ENCODING_ERROR,
0376 IDNA_ROUNDTRIP_VERIFY_ERROR = IDN2_ENCODING_ERROR,
0377 IDNA_CONTAINS_ACE_PREFIX = IDN2_ENCODING_ERROR,
0378 IDNA_ICONV_ERROR = IDN2_ENCODING_ERROR,
0379 IDNA_MALLOC_ERROR = IDN2_MALLOC,
0380 IDNA_DLOPEN_ERROR = IDN2_MALLOC
0381 } Idna_rc;
0382
0383
0384
0385
0386
0387
0388
0389
0390 typedef enum
0391 {
0392 IDNA_ALLOW_UNASSIGNED = IDN2_ALLOW_UNASSIGNED,
0393 IDNA_USE_STD3_ASCII_RULES = IDN2_USE_STD3_ASCII_RULES
0394 } Idna_flags;
0395
0396 # define idna_to_ascii_4i(i,l,o,f) idn2_to_ascii_4i(i,l,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0397 # define idna_to_ascii_4z(i,o,f) idn2_to_ascii_4z(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0398 # define idna_to_ascii_8z(i,o,f) idn2_to_ascii_8z(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0399 # define idna_to_ascii_lz(i,o,f) idn2_to_ascii_lz(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0400
0401 # define idna_to_unicode_8z4z idn2_to_unicode_8z4z
0402 # define idna_to_unicode_4z4z idn2_to_unicode_4z4z
0403 # define idna_to_unicode_44i idn2_to_unicode_44i
0404 # define idna_to_unicode_8z8z idn2_to_unicode_8z8z
0405 # define idna_to_unicode_8zlz idn2_to_unicode_8zlz
0406 # define idna_to_unicode_lzlz idn2_to_unicode_lzlz
0407
0408 # define idna_strerror idn2_strerror
0409 # define idn_free idn2_free
0410
0411 # endif
0412 # endif
0413
0414 # ifdef __cplusplus
0415 }
0416 # endif
0417
0418 #endif