libidn: idna.h Source File

libidn 1.33

idna.h
Go to the documentation of this file.
1 /* idna.h --- Prototypes for Internationalized Domain Name library.
2 Copyright (C) 2002-2016 Simon Josefsson
3
4 This file is part of GNU Libidn.
5
6 GNU Libidn is free software: you can redistribute it and/or
7 modify it under the terms of either:
8
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version.
12
13 or
14
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version.
18
19 or both in parallel, as here.
20
21 GNU Libidn is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
29
30 #ifndef IDNA_H
31 # define IDNA_H
32
33 # ifndef IDNAPI
34 # if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
35 # define IDNAPI __attribute__((__visibility__("default")))
36 # elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
37 # define IDNAPI __declspec(dllexport)
38 # elif defined _MSC_VER && ! defined LIBIDN_STATIC
39 # define IDNAPI __declspec(dllimport)
40 # else
41 # define IDNAPI
42 # endif
43 # endif
44
45 # include <stddef.h> /* size_t */
46 # include <idn-int.h> /* uint32_t */
47
48 # ifdef __cplusplus
49 extern "C"
50 {
51 # endif
52
53 /* Error codes. */
54 typedef enum
55 {
56 IDNA_SUCCESS = 0,
57 IDNA_STRINGPREP_ERROR = 1,
58 IDNA_PUNYCODE_ERROR = 2,
59 IDNA_CONTAINS_NON_LDH = 3,
60 /* Workaround typo in earlier versions. */
61 IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
62 IDNA_CONTAINS_MINUS = 4,
63 IDNA_INVALID_LENGTH = 5,
64 IDNA_NO_ACE_PREFIX = 6,
65 IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
66 IDNA_CONTAINS_ACE_PREFIX = 8,
67 IDNA_ICONV_ERROR = 9,
68 /* Internal errors. */
69 IDNA_MALLOC_ERROR = 201,
70 IDNA_DLOPEN_ERROR = 202
71 } Idna_rc;
72
73 /* IDNA flags */
74 typedef enum
75 {
76 IDNA_ALLOW_UNASSIGNED = 0x0001,
77 IDNA_USE_STD3_ASCII_RULES = 0x0002
78 } Idna_flags;
79
80 # ifndef IDNA_ACE_PREFIX
81 # define IDNA_ACE_PREFIX "xn--"
82 # endif
83
84 extern IDNAPI const char *idna_strerror (Idna_rc rc);
85
86 /* Core functions */
87 extern IDNAPI int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
88 char *out, int flags);
89 extern IDNAPI int idna_to_unicode_44i (const uint32_t * in, size_t inlen,
90 uint32_t * out, size_t * outlen,
91 int flags);
92
93 /* Wrappers that handle several labels */
94
95 extern IDNAPI int idna_to_ascii_4z (const uint32_t * input,
96 char **output, int flags);
97
98 extern IDNAPI int idna_to_ascii_8z (const char *input, char **output,
99 int flags);
100
101 extern IDNAPI int idna_to_ascii_lz (const char *input, char **output,
102 int flags);
103
104 extern IDNAPI int idna_to_unicode_4z4z (const uint32_t * input,
105 uint32_t ** output, int flags);
106
107 extern IDNAPI int idna_to_unicode_8z4z (const char *input,
108 uint32_t ** output, int flags);
109
110 extern IDNAPI int idna_to_unicode_8z8z (const char *input,
111 char **output, int flags);
112
113 extern IDNAPI int idna_to_unicode_8zlz (const char *input,
114 char **output, int flags);
115
116 extern IDNAPI int idna_to_unicode_lzlz (const char *input,
117 char **output, int flags);
118
119 # ifdef __cplusplus
120 }
121 # endif
122
123 #endif /* IDNA_H */
IDNA_NO_ACE_PREFIX
Definition: idna.h:64
IDNA_CONTAINS_ACE_PREFIX
Definition: idna.h:66
IDNA_DLOPEN_ERROR
Definition: idna.h:70
IDNA_INVALID_LENGTH
Definition: idna.h:63
IDNA_USE_STD3_ASCII_RULES
Definition: idna.h:77
idna_to_ascii_8z
IDNAPI int idna_to_ascii_8z(const char *input, char **output, int flags)
Definition: idna.c:575
idna_to_unicode_8zlz
IDNAPI int idna_to_unicode_8zlz(const char *input, char **output, int flags)
Definition: idna.c:780
IDNA_STRINGPREP_ERROR
Definition: idna.h:57
IDNA_CONTAINS_MINUS
Definition: idna.h:62
idna_to_ascii_4i
IDNAPI int idna_to_ascii_4i(const uint32_t *in, size_t inlen, char *out, int flags)
Definition: idna.c:81
idna_to_unicode_8z8z
IDNAPI int idna_to_unicode_8z8z(const char *input, char **output, int flags)
Definition: idna.c:746
IDNA_ALLOW_UNASSIGNED
Definition: idna.h:76
idna_to_unicode_8z4z
IDNAPI int idna_to_unicode_8z4z(const char *input, uint32_t **output, int flags)
Definition: idna.c:715
idna_to_unicode_4z4z
IDNAPI int idna_to_unicode_4z4z(const uint32_t *input, uint32_t **output, int flags)
Definition: idna.c:639
IDNA_ICONV_ERROR
Definition: idna.h:67
IDNA_ROUNDTRIP_VERIFY_ERROR
Definition: idna.h:65
IDNA_MALLOC_ERROR
Definition: idna.h:69
IDNA_PUNYCODE_ERROR
Definition: idna.h:58
idna_to_unicode_lzlz
IDNAPI int idna_to_unicode_lzlz(const char *input, char **output, int flags)
Definition: idna.c:815
IDNA_CONTAINS_NON_LDH
Definition: idna.h:59
Idna_rc
Idna_rc
Definition: idna.h:54
IDNAPI
#define IDNAPI
Definition: idna.h:41
idna_to_ascii_lz
IDNAPI int idna_to_ascii_lz(const char *input, char **output, int flags)
Definition: idna.c:608
Idna_flags
Idna_flags
Definition: idna.h:74
IDNA_SUCCESS
Definition: idna.h:56
idna_to_unicode_44i
IDNAPI int idna_to_unicode_44i(const uint32_t *in, size_t inlen, uint32_t *out, size_t *outlen, int flags)
Definition: idna.c:436
IDNA_CONTAINS_LDH
Definition: idna.h:61
idna_strerror
IDNAPI const char * idna_strerror(Idna_rc rc)
Definition: strerror-idna.c:73
idna_to_ascii_4z
IDNAPI int idna_to_ascii_4z(const uint32_t *input, char **output, int flags)
Definition: idna.c:476