Add.
[libidn.git] / idna.h
blobcb175a09fbccb36e2c20144bc99277e7a7a978d3
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 /* Error codes. */
31 enum
33 IDNA_SUCCESS = 0,
34 IDNA_STRINGPREP_ERROR = 1,
35 IDNA_PUNYCODE_ERROR = 2,
36 IDNA_CONTAINS_LDH = 3,
37 IDNA_CONTAINS_MINUS = 4,
38 IDNA_INVALID_LENGTH = 5,
39 IDNA_NO_ACE_PREFIX = 6,
40 IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
41 IDNA_CONTAINS_ACE_PREFIX = 8,
42 IDNA_ICONV_ERROR = 9,
43 /* Internal errors. */
44 IDNA_MALLOC_ERROR = 201
47 #ifndef IDNA_ACE_PREFIX
48 #define IDNA_ACE_PREFIX "xn--"
49 #endif
51 extern int idna_to_ascii (const unsigned long *in,
52 size_t inlen,
53 char *out,
54 int allowunassigned,
55 int usestd3asciirules);
57 extern int idna_to_ascii_from_ucs4 (const unsigned long *input,
58 char **output,
59 int allowunassigned,
60 int usestd3asciirules);
62 extern int idna_to_ascii_from_utf8 (const char *input,
63 char **output,
64 int allowunassigned,
65 int usestd3asciirules);
67 extern int idna_to_ascii_from_locale (const char *input,
68 char **output,
69 int allowunassigned,
70 int usestd3asciirules);
72 extern int idna_to_unicode (const unsigned long *in,
73 size_t inlen,
74 unsigned long *out,
75 size_t * outlen,
76 int allowunassigned,
77 int usestd3asciirules);
79 extern int idna_to_unicode_ucs4_from_ucs4 (const unsigned long *input,
80 unsigned long **output,
81 int allowunassigned,
82 int usestd3asciirules);
84 extern int idna_to_unicode_ucs4_from_utf8 (const char *input,
85 unsigned long **output,
86 int allowunassigned,
87 int usestd3asciirules);
89 extern int idna_to_unicode_utf8_from_utf8 (const char *input,
90 char **output,
91 int allowunassigned,
92 int usestd3asciirules);
94 extern int idna_to_unicode_locale_from_utf8 (const char *input,
95 char **output,
96 int allowunassigned,
97 int usestd3asciirules);
99 extern int idna_to_unicode_locale_from_locale (const char *input,
100 char **output,
101 int allowunassigned,
102 int usestd3asciirules);
104 /* Deprecated interfaces */
106 extern int idna_ucs4_to_ace (const unsigned long *input, char **output);
107 extern int idna_utf8_to_ace (const char *input, char **output);
108 extern int idna_locale_to_ace (const char *input, char **output);
110 extern int idna_ucs4ace_to_ucs4 (const unsigned long *input,
111 unsigned long **output);
112 extern int idna_utf8ace_to_ucs4 (const char *input, unsigned long **output);
113 extern int idna_utf8ace_to_utf8 (const char *input, char **output);
114 extern int idna_utf8ace_to_locale (const char *input, char **output);
115 extern int idna_localeace_to_locale (const char *input, char **output);
117 #ifdef __cplusplus
119 #endif
120 #endif /* _PUNYCODE_H */