File indexing completed on 2024-05-18 08:30:02
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(3,1)
0106 # define G_GNUC_DEPRECATED __attribute__((deprecated))
0107 # elif defined(_MSC_VER)
0108 # define G_GNUC_DEPRECATED __declspec(deprecated)
0109 # else
0110 # define G_GNUC_DEPRECATED
0111 # endif
0112
0113
0114
0115
0116
0117
0118 # if GCC_VERSION_AT_LEAST(2,95)
0119 # define G_GNUC_UNUSED __attribute__ ((__unused__))
0120 # else
0121 # define G_GNUC_UNUSED
0122 # endif
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 # define IDN2_VERSION "2.3.4"
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 # define IDN2_VERSION_NUMBER 0x02030004
0144
0145
0146
0147
0148
0149
0150
0151 # define IDN2_VERSION_MAJOR 2
0152
0153
0154
0155
0156
0157
0158
0159 # define IDN2_VERSION_MINOR 3
0160
0161
0162
0163
0164
0165
0166
0167 # define IDN2_VERSION_PATCH 4
0168
0169
0170
0171
0172
0173
0174
0175 # define IDN2_LABEL_MAX_LENGTH 63
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 # define IDN2_DOMAIN_MAX_LENGTH 255
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 typedef enum
0205 {
0206 IDN2_NFC_INPUT = 1,
0207 IDN2_ALABEL_ROUNDTRIP = 2,
0208 IDN2_TRANSITIONAL = 4,
0209 IDN2_NONTRANSITIONAL = 8,
0210 IDN2_ALLOW_UNASSIGNED = 16,
0211 IDN2_USE_STD3_ASCII_RULES = 32,
0212 IDN2_NO_TR46 = 64,
0213 IDN2_NO_ALABEL_ROUNDTRIP = 128
0214 } idn2_flags;
0215
0216
0217
0218 extern _IDN2_API int
0219 idn2_lookup_u8 (const uint8_t * src, uint8_t ** lookupname, int flags);
0220
0221 extern _IDN2_API int
0222 idn2_register_u8 (const uint8_t * ulabel, const uint8_t * alabel,
0223 uint8_t ** insertname, int flags);
0224
0225
0226
0227 extern _IDN2_API int
0228 idn2_lookup_ul (const char *src, char **lookupname, int flags);
0229
0230 extern _IDN2_API int
0231 idn2_register_ul (const char *ulabel, const char *alabel,
0232 char **insertname, int flags);
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
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 typedef enum
0274 {
0275 IDN2_OK = 0,
0276 IDN2_MALLOC = -100,
0277 IDN2_NO_CODESET = -101,
0278 IDN2_ICONV_FAIL = -102,
0279 IDN2_ENCODING_ERROR = -200,
0280 IDN2_NFC = -201,
0281 IDN2_PUNYCODE_BAD_INPUT = -202,
0282 IDN2_PUNYCODE_BIG_OUTPUT = -203,
0283 IDN2_PUNYCODE_OVERFLOW = -204,
0284 IDN2_TOO_BIG_DOMAIN = -205,
0285 IDN2_TOO_BIG_LABEL = -206,
0286 IDN2_INVALID_ALABEL = -207,
0287 IDN2_UALABEL_MISMATCH = -208,
0288 IDN2_INVALID_FLAGS = -209,
0289 IDN2_NOT_NFC = -300,
0290 IDN2_2HYPHEN = -301,
0291 IDN2_HYPHEN_STARTEND = -302,
0292 IDN2_LEADING_COMBINING = -303,
0293 IDN2_DISALLOWED = -304,
0294 IDN2_CONTEXTJ = -305,
0295 IDN2_CONTEXTJ_NO_RULE = -306,
0296 IDN2_CONTEXTO = -307,
0297 IDN2_CONTEXTO_NO_RULE = -308,
0298 IDN2_UNASSIGNED = -309,
0299 IDN2_BIDI = -310,
0300 IDN2_DOT_IN_LABEL = -311,
0301 IDN2_INVALID_TRANSITIONAL = -312,
0302 IDN2_INVALID_NONTRANSITIONAL = -313,
0303 IDN2_ALABEL_ROUNDTRIP_FAILED = -314,
0304 } idn2_rc;
0305
0306
0307
0308 extern _IDN2_API int
0309 idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char *output,
0310 int flags) G_GNUC_DEPRECATED;
0311 extern _IDN2_API int idn2_to_ascii_4i2 (const uint32_t * input,
0312 size_t inlen, char **output,
0313 int flags);
0314 extern _IDN2_API int idn2_to_ascii_4z (const uint32_t * input,
0315 char **output, int flags);
0316 extern _IDN2_API int idn2_to_ascii_8z (const char *input, char **output,
0317 int flags);
0318 extern _IDN2_API int idn2_to_ascii_lz (const char *input, char **output,
0319 int flags);
0320
0321 extern _IDN2_API int
0322 idn2_to_unicode_8z4z (const char *input, uint32_t ** output,
0323 int flags G_GNUC_UNUSED);
0324 extern _IDN2_API int idn2_to_unicode_4z4z (const uint32_t * input,
0325 uint32_t ** output, int flags);
0326 extern _IDN2_API int idn2_to_unicode_44i (const uint32_t * in, size_t inlen,
0327 uint32_t * out, size_t *outlen,
0328 int flags);
0329 extern _IDN2_API int idn2_to_unicode_8z8z (const char *input, char **output,
0330 int flags);
0331 extern _IDN2_API int idn2_to_unicode_8zlz (const char *input, char **output,
0332 int flags);
0333 extern _IDN2_API int idn2_to_unicode_lzlz (const char *input, char **output,
0334 int flags);
0335
0336 extern _IDN2_API const char *idn2_strerror (int rc)
0337 G_GNUC_IDN2_ATTRIBUTE_CONST;
0338 extern _IDN2_API const char *idn2_strerror_name (int rc)
0339 G_GNUC_IDN2_ATTRIBUTE_CONST;
0340
0341 extern _IDN2_API const char *idn2_check_version (const char *req_version)
0342 G_GNUC_IDN2_ATTRIBUTE_PURE;
0343
0344 extern _IDN2_API void idn2_free (void *ptr);
0345
0346 # ifndef __GTK_DOC_IGNORE__
0347
0348 # if !defined IDNA_H && !defined IDN2_SKIP_LIBIDN_COMPAT
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371 typedef enum
0372 {
0373 IDNA_SUCCESS = IDN2_OK,
0374 IDNA_STRINGPREP_ERROR = IDN2_ENCODING_ERROR,
0375 IDNA_PUNYCODE_ERROR = IDN2_PUNYCODE_BAD_INPUT,
0376 IDNA_CONTAINS_NON_LDH = IDN2_ENCODING_ERROR,
0377 IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
0378 IDNA_CONTAINS_MINUS = IDN2_ENCODING_ERROR,
0379 IDNA_INVALID_LENGTH = IDN2_DISALLOWED,
0380 IDNA_NO_ACE_PREFIX = IDN2_ENCODING_ERROR,
0381 IDNA_ROUNDTRIP_VERIFY_ERROR = IDN2_ENCODING_ERROR,
0382 IDNA_CONTAINS_ACE_PREFIX = IDN2_ENCODING_ERROR,
0383 IDNA_ICONV_ERROR = IDN2_ENCODING_ERROR,
0384 IDNA_MALLOC_ERROR = IDN2_MALLOC,
0385 IDNA_DLOPEN_ERROR = IDN2_MALLOC
0386 } Idna_rc;
0387
0388
0389
0390
0391
0392
0393
0394
0395 typedef enum
0396 {
0397 IDNA_ALLOW_UNASSIGNED = IDN2_ALLOW_UNASSIGNED,
0398 IDNA_USE_STD3_ASCII_RULES = IDN2_USE_STD3_ASCII_RULES
0399 } Idna_flags;
0400
0401 # define idna_to_ascii_4i(i,l,o,f) idn2_to_ascii_4i(i,l,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0402 # define idna_to_ascii_4z(i,o,f) idn2_to_ascii_4z(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0403 # define idna_to_ascii_8z(i,o,f) idn2_to_ascii_8z(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0404 # define idna_to_ascii_lz(i,o,f) idn2_to_ascii_lz(i,o,f|IDN2_NFC_INPUT|IDN2_NONTRANSITIONAL)
0405
0406 # define idna_to_unicode_8z4z idn2_to_unicode_8z4z
0407 # define idna_to_unicode_4z4z idn2_to_unicode_4z4z
0408 # define idna_to_unicode_44i idn2_to_unicode_44i
0409 # define idna_to_unicode_8z8z idn2_to_unicode_8z8z
0410 # define idna_to_unicode_8zlz idn2_to_unicode_8zlz
0411 # define idna_to_unicode_lzlz idn2_to_unicode_lzlz
0412
0413 # define idna_strerror idn2_strerror
0414 # define idn_free idn2_free
0415
0416 # endif
0417 # endif
0418
0419 # ifdef __cplusplus
0420 }
0421 # endif
0422
0423 #endif