libidn  1.42
idna.h
Go to the documentation of this file.
1 /* idna.h --- Prototypes for Internationalized Domain Name library.
2  Copyright (C) 2002-2024 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  {
78  /* Workaround typo in earlier versions. */
86  /* Internal errors. */
88  IDNA_DLOPEN_ERROR = 202
90 
91  /* IDNA flags */
92  typedef enum
93  {
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 */
IDNAPI int idna_to_ascii_4i(const uint32_t *in, size_t inlen, char *out, int flags)
Definition: idna.c:81
Idna_rc
Definition: idna.h:73
@ IDNA_ROUNDTRIP_VERIFY_ERROR
Definition: idna.h:83
@ IDNA_PUNYCODE_ERROR
Definition: idna.h:76
@ IDNA_SUCCESS
Definition: idna.h:74
@ IDNA_NO_ACE_PREFIX
Definition: idna.h:82
@ IDNA_CONTAINS_LDH
Definition: idna.h:79
@ IDNA_CONTAINS_MINUS
Definition: idna.h:80
@ IDNA_ICONV_ERROR
Definition: idna.h:85
@ IDNA_STRINGPREP_ERROR
Definition: idna.h:75
@ IDNA_CONTAINS_ACE_PREFIX
Definition: idna.h:84
@ IDNA_CONTAINS_NON_LDH
Definition: idna.h:77
@ IDNA_INVALID_LENGTH
Definition: idna.h:81
@ IDNA_MALLOC_ERROR
Definition: idna.h:87
@ IDNA_DLOPEN_ERROR
Definition: idna.h:88
IDNAPI int idna_to_unicode_8z4z(const char *input, uint32_t **output, int flags)
Definition: idna.c:719
IDNAPI int idna_to_unicode_8zlz(const char *input, char **output, int flags)
Definition: idna.c:784
IDNAPI int idna_to_ascii_4z(const uint32_t *input, char **output, int flags)
Definition: idna.c:477
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
#define IDNAPI
Definition: idna.h:59
IDNAPI int idna_to_unicode_4z4z(const uint32_t *input, uint32_t **output, int flags)
Definition: idna.c:640
IDNAPI int idna_to_unicode_8z8z(const char *input, char **output, int flags)
Definition: idna.c:750
IDNAPI int idna_to_ascii_lz(const char *input, char **output, int flags)
Definition: idna.c:609
Idna_flags
Definition: idna.h:93
@ IDNA_USE_STD3_ASCII_RULES
Definition: idna.h:95
@ IDNA_ALLOW_UNASSIGNED
Definition: idna.h:94
IDNAPI int idna_to_ascii_8z(const char *input, char **output, int flags)
Definition: idna.c:576
IDNAPI const char * idna_strerror(Idna_rc rc)
Definition: strerror-idna.c:73
IDNAPI int idna_to_unicode_lzlz(const char *input, char **output, int flags)
Definition: idna.c:819