Remove obsolete test (we break backwards compatibility).
[libidn.git] / idna.h
blobd62a451e9848b6139c51d1709cd981169c744ee9
1 /* idna.h Declarations for IDNA.
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of GNU Libidn.
6 * GNU Libidn is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * GNU Libidn is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with GNU Libidn; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _IDNA_H
23 #define _IDNA_H
25 #ifdef __cplusplus
26 extern "C"
28 #endif
30 #include <stddef.h> /* size_t */
31 #include <idn-int.h> /* uint32_t */
33 /* Error codes. */
34 enum
36 IDNA_SUCCESS = 0,
37 IDNA_STRINGPREP_ERROR = 1,
38 IDNA_PUNYCODE_ERROR = 2,
39 IDNA_CONTAINS_LDH = 3,
40 IDNA_CONTAINS_MINUS = 4,
41 IDNA_INVALID_LENGTH = 5,
42 IDNA_NO_ACE_PREFIX = 6,
43 IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
44 IDNA_CONTAINS_ACE_PREFIX = 8,
45 IDNA_ICONV_ERROR = 9,
46 /* Internal errors. */
47 IDNA_MALLOC_ERROR = 201
50 /* IDNA flags */
51 enum
53 IDNA_ALLOW_UNASSIGNED = 0x0001,
54 IDNA_USE_STD3_ASCII_RULES = 0x0002
57 #ifndef IDNA_ACE_PREFIX
58 #define IDNA_ACE_PREFIX "xn--"
59 #endif
61 /* Core functions */
62 extern int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
63 char *out, int flags);
64 extern int idna_to_unicode_44i (const uint32_t * in, size_t inlen,
65 uint32_t * out, size_t * outlen, int flags);
67 /* Wrappers that handle several labels */
69 extern int idna_to_ascii_4z (const uint32_t * input, char **output,
70 int flags);
72 extern int idna_to_ascii_8z (const char *input, char **output, int flags);
74 extern int idna_to_ascii_lz (const char *input, char **output, int flags);
77 extern int idna_to_unicode_4z4z (const uint32_t * input, uint32_t ** output,
78 int flags);
80 extern int idna_to_unicode_8z4z (const char *input, uint32_t ** output,
81 int flags);
83 extern int idna_to_unicode_8z8z (const char *input, char **output,
84 int flags);
86 extern int idna_to_unicode_8zlz (const char *input, char **output,
87 int flags);
89 extern int idna_to_unicode_lzlz (const char *input, char **output,
90 int flags);
92 /* Deprecated interfaces */
94 extern int idna_to_ascii (const unsigned long *in,
95 size_t inlen,
96 char *out,
97 int allowunassigned, int usestd3asciirules);
99 extern int idna_to_ascii_from_ucs4 (const unsigned long *input,
100 char **output,
101 int allowunassigned,
102 int usestd3asciirules);
104 extern int idna_to_ascii_from_utf8 (const char *input,
105 char **output,
106 int allowunassigned,
107 int usestd3asciirules);
109 extern int idna_to_ascii_from_locale (const char *input,
110 char **output,
111 int allowunassigned,
112 int usestd3asciirules);
114 extern int idna_to_unicode (const unsigned long *in,
115 size_t inlen,
116 unsigned long *out,
117 size_t * outlen,
118 int allowunassigned, int usestd3asciirules);
120 extern int idna_to_unicode_ucs4_from_ucs4 (const unsigned long *input,
121 unsigned long **output,
122 int allowunassigned,
123 int usestd3asciirules);
125 extern int idna_to_unicode_ucs4_from_utf8 (const char *input,
126 unsigned long **output,
127 int allowunassigned,
128 int usestd3asciirules);
130 extern int idna_to_unicode_utf8_from_utf8 (const char *input,
131 char **output,
132 int allowunassigned,
133 int usestd3asciirules);
135 extern int idna_to_unicode_locale_from_utf8 (const char *input,
136 char **output,
137 int allowunassigned,
138 int usestd3asciirules);
140 extern int idna_to_unicode_locale_from_locale (const char *input,
141 char **output,
142 int allowunassigned,
143 int usestd3asciirules);
145 /* Deprecated interfaces (even older) */
147 extern int idna_ucs4_to_ace (const unsigned long *input, char **output);
148 extern int idna_utf8_to_ace (const char *input, char **output);
149 extern int idna_locale_to_ace (const char *input, char **output);
151 extern int idna_ucs4ace_to_ucs4 (const unsigned long *input,
152 unsigned long **output);
153 extern int idna_utf8ace_to_ucs4 (const char *input, unsigned long **output);
154 extern int idna_utf8ace_to_utf8 (const char *input, char **output);
155 extern int idna_utf8ace_to_locale (const char *input, char **output);
156 extern int idna_localeace_to_locale (const char *input, char **output);
158 #ifdef __cplusplus
160 #endif
161 #endif /* _PUNYCODE_H */