libidn 1.43

idna.h
Go to the documentation of this file.
1/* idna.h --- Prototypes for Internationalized Domain Name library.
2 Copyright (C) 2002-2025 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 <https://www.gnu.org/licenses/>. */
29
30#ifndef IDNA_H
31# define IDNA_H
32
51# ifndef IDNAPI
52# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
53# define IDNAPI __attribute__((__visibility__("default")))
54# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
55# define IDNAPI __declspec(dllexport)
56# elif defined _MSC_VER && ! defined LIBIDN_STATIC
57# define IDNAPI __declspec(dllimport)
58# else
59# define IDNAPI
60# endif
61# endif
62
63# include <stddef.h> /* size_t */
64# include <idn-int.h> /* uint32_t */
65
66# ifdef __cplusplus
67 extern "C"
68{
69# endif
70
71 /* Error codes. */
72 typedef enum
73 {
74 IDNA_SUCCESS = 0,
75 IDNA_STRINGPREP_ERROR = 1,
76 IDNA_PUNYCODE_ERROR = 2,
77 IDNA_CONTAINS_NON_LDH = 3,
78 /* Workaround typo in earlier versions. */
79 IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
80 IDNA_CONTAINS_MINUS = 4,
81 IDNA_INVALID_LENGTH = 5,
82 IDNA_NO_ACE_PREFIX = 6,
83 IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
84 IDNA_CONTAINS_ACE_PREFIX = 8,
85 IDNA_ICONV_ERROR = 9,
86 /* Internal errors. */
87 IDNA_MALLOC_ERROR = 201,
88 IDNA_DLOPEN_ERROR = 202
89 } Idna_rc;
90
91 /* IDNA flags */
92 typedef enum
93 {
94 IDNA_ALLOW_UNASSIGNED = 0x0001,
95 IDNA_USE_STD3_ASCII_RULES = 0x0002
96 } Idna_flags;
97
98# ifndef IDNA_ACE_PREFIX
99# define IDNA_ACE_PREFIX "xn--"
100# endif
101
102 extern IDNAPI const char *idna_strerror (Idna_rc rc);
103
104 /* Core functions */
105 extern IDNAPI int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
106 char *out, int flags);
107 extern IDNAPI int idna_to_unicode_44i (const uint32_t * in, size_t inlen,
108 uint32_t * out, size_t *outlen,
109 int flags);
110
111 /* Wrappers that handle several labels */
112
113 extern IDNAPI int idna_to_ascii_4z (const uint32_t * input,
114 char **output, int flags);
115
116 extern IDNAPI int idna_to_ascii_8z (const char *input, char **output,
117 int flags);
118
119 extern IDNAPI int idna_to_ascii_lz (const char *input, char **output,
120 int flags);
121
122 extern IDNAPI int idna_to_unicode_4z4z (const uint32_t * input,
123 uint32_t ** output, int flags);
124
125 extern IDNAPI int idna_to_unicode_8z4z (const char *input,
126 uint32_t ** output, int flags);
127
128 extern IDNAPI int idna_to_unicode_8z8z (const char *input,
129 char **output, int flags);
130
131 extern IDNAPI int idna_to_unicode_8zlz (const char *input,
132 char **output, int flags);
133
134 extern IDNAPI int idna_to_unicode_lzlz (const char *input,
135 char **output, int flags);
136
137# ifdef __cplusplus
138}
139# endif
140
141#endif /* IDNA_H */
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_rc
Idna_rc
Definition idna.h:73
IDNA_ROUNDTRIP_VERIFY_ERROR
@ IDNA_ROUNDTRIP_VERIFY_ERROR
Definition idna.h:83
IDNA_PUNYCODE_ERROR
@ IDNA_PUNYCODE_ERROR
Definition idna.h:76
IDNA_SUCCESS
@ IDNA_SUCCESS
Definition idna.h:74
IDNA_NO_ACE_PREFIX
@ IDNA_NO_ACE_PREFIX
Definition idna.h:82
IDNA_CONTAINS_LDH
@ IDNA_CONTAINS_LDH
Definition idna.h:79
IDNA_CONTAINS_MINUS
@ IDNA_CONTAINS_MINUS
Definition idna.h:80
IDNA_ICONV_ERROR
@ IDNA_ICONV_ERROR
Definition idna.h:85
IDNA_STRINGPREP_ERROR
@ IDNA_STRINGPREP_ERROR
Definition idna.h:75
IDNA_CONTAINS_ACE_PREFIX
@ IDNA_CONTAINS_ACE_PREFIX
Definition idna.h:84
IDNA_CONTAINS_NON_LDH
@ IDNA_CONTAINS_NON_LDH
Definition idna.h:77
IDNA_INVALID_LENGTH
@ IDNA_INVALID_LENGTH
Definition idna.h:81
IDNA_MALLOC_ERROR
@ IDNA_MALLOC_ERROR
Definition idna.h:87
IDNA_DLOPEN_ERROR
@ IDNA_DLOPEN_ERROR
Definition idna.h:88
idna_to_unicode_8z4z
IDNAPI int idna_to_unicode_8z4z(const char *input, uint32_t **output, int flags)
Definition idna.c:726
idna_to_unicode_8zlz
IDNAPI int idna_to_unicode_8zlz(const char *input, char **output, int flags)
Definition idna.c:791
idna_to_ascii_4z
IDNAPI int idna_to_ascii_4z(const uint32_t *input, char **output, int flags)
Definition idna.c:477
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:437
IDNAPI
#define IDNAPI
Definition idna.h:59
idna_to_unicode_4z4z
IDNAPI int idna_to_unicode_4z4z(const uint32_t *input, uint32_t **output, int flags)
Definition idna.c:640
idna_strerror
IDNAPI const char * idna_strerror(Idna_rc rc)
Definition strerror-idna.c:73
idna_to_unicode_8z8z
IDNAPI int idna_to_unicode_8z8z(const char *input, char **output, int flags)
Definition idna.c:757
idna_to_ascii_lz
IDNAPI int idna_to_ascii_lz(const char *input, char **output, int flags)
Definition idna.c:609
Idna_flags
Idna_flags
Definition idna.h:93
IDNA_USE_STD3_ASCII_RULES
@ IDNA_USE_STD3_ASCII_RULES
Definition idna.h:95
IDNA_ALLOW_UNASSIGNED
@ IDNA_ALLOW_UNASSIGNED
Definition idna.h:94
idna_to_ascii_8z
IDNAPI int idna_to_ascii_8z(const char *input, char **output, int flags)
Definition idna.c:576
idna_to_unicode_lzlz
IDNAPI int idna_to_unicode_lzlz(const char *input, char **output, int flags)
Definition idna.c:826