CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / netwerk / dns / nsIDNKitInterface.h
blob41d58c6d655dd8f000ad6ac13b9a56f9510c8018
1 /*
2 * Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved.
3 *
4 * By using this file, you agree to the terms and conditions set forth bellow.
5 *
6 * LICENSE TERMS AND CONDITIONS
7 *
8 * The following License Terms and Conditions apply, unless a different
9 * license is obtained from Japan Network Information Center ("JPNIC"),
10 * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
11 * Chiyoda-ku, Tokyo 101-0047, Japan.
13 * 1. Use, Modification and Redistribution (including distribution of any
14 * modified or derived work) in source and/or binary forms is permitted
15 * under this License Terms and Conditions.
17 * 2. Redistribution of source code must retain the copyright notices as they
18 * appear in each source code file, this License Terms and Conditions.
20 * 3. Redistribution in binary form must reproduce the Copyright Notice,
21 * this License Terms and Conditions, in the documentation and/or other
22 * materials provided with the distribution. For the purposes of binary
23 * distribution the "Copyright Notice" refers to the following language:
24 * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
26 * 4. The name of JPNIC may not be used to endorse or promote products
27 * derived from this Software without specific prior written approval of
28 * JPNIC.
30 * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
33 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
43 #ifndef nsIDNKitWrapper_h__
44 #define nsIDNKitWrapper_h__
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
50 #include "prtypes.h"
53 * libidnkit result code.
55 typedef enum {
56 idn_success,
57 idn_notfound,
58 idn_invalid_encoding,
59 idn_invalid_syntax,
60 idn_invalid_name,
61 idn_invalid_message,
62 idn_invalid_action,
63 idn_invalid_codepoint,
64 idn_invalid_length,
65 idn_buffer_overflow,
66 idn_noentry,
67 idn_nomemory,
68 idn_nofile,
69 idn_nomapping,
70 idn_context_required,
71 idn_prohibited,
72 idn_failure /* !!This must be the last one!! */
73 } idn_result_t;
76 * BIDI type codes.
77 */
78 typedef enum {
79 idn_biditype_r_al,
80 idn_biditype_l,
81 idn_biditype_others
82 } idn_biditype_t;
85 * A Handle for nameprep operations.
87 typedef struct idn_nameprep *idn_nameprep_t;
91 * The latest version of nameprep.
93 #define IDN_NAMEPREP_CURRENT "nameprep-11"
95 #undef assert
96 #define assert(a)
97 #define TRACE(a)
100 /* race.c */
101 idn_result_t race_decode_decompress(const char *from,
102 PRUint16 *buf,
103 size_t buflen);
104 idn_result_t race_compress_encode(const PRUint16 *p,
105 int compress_mode,
106 char *to, size_t tolen);
107 int get_compress_mode(PRUint16 *p);
110 /* nameprep.c */
113 * Create a handle for nameprep operations.
114 * The handle is stored in '*handlep', which is used other functions
115 * in this module.
116 * The version of the NAMEPREP specification can be specified with
117 * 'version' parameter. If 'version' is NULL, the latest version
118 * is used.
120 * Returns:
121 * idn_success -- ok.
122 * idn_notfound -- specified version not found.
124 idn_result_t
125 idn_nameprep_create(const char *version, idn_nameprep_t *handlep);
128 * Close a handle, which was created by 'idn_nameprep_create'.
130 void
131 idn_nameprep_destroy(idn_nameprep_t handle);
134 * Perform character mapping on an UCS4 string specified by 'from', and
135 * store the result into 'to', whose length is specified by 'tolen'.
137 * Returns:
138 * idn_success -- ok.
139 * idn_buffer_overflow -- result buffer is too small.
141 idn_result_t
142 idn_nameprep_map(idn_nameprep_t handle, const PRUint32 *from,
143 PRUint32 *to, size_t tolen);
146 * Check if an UCS4 string 'str' contains any prohibited characters specified
147 * by the draft. If found, the pointer to the first such character is stored
148 * into '*found'. Otherwise '*found' will be NULL.
150 * Returns:
151 * idn_success -- check has been done properly. (But this
152 * does not mean that no prohibited character
153 * was found. Check '*found' to see the
154 * result.)
156 idn_result_t
157 idn_nameprep_isprohibited(idn_nameprep_t handle, const PRUint32 *str,
158 const PRUint32 **found);
161 * Check if an UCS4 string 'str' contains any unassigned characters specified
162 * by the draft. If found, the pointer to the first such character is stored
163 * into '*found'. Otherwise '*found' will be NULL.
165 * Returns:
166 * idn_success -- check has been done properly. (But this
167 * does not mean that no unassinged character
168 * was found. Check '*found' to see the
169 * result.)
171 idn_result_t
172 idn_nameprep_isunassigned(idn_nameprep_t handle, const PRUint32 *str,
173 const PRUint32 **found);
176 * Check if an UCS4 string 'str' is valid string specified by ``bidi check''
177 * of the draft. If it is not valid, the pointer to the first invalid
178 * character is stored into '*found'. Otherwise '*found' will be NULL.
180 * Returns:
181 * idn_success -- check has been done properly. (But this
182 * does not mean that the string was valid.
183 * Check '*found' to see the result.)
185 idn_result_t
186 idn_nameprep_isvalidbidi(idn_nameprep_t handle, const PRUint32 *str,
187 const PRUint32 **found);
191 #ifdef __cplusplus
193 #endif /* __cplusplus */
195 #endif /* nsIDNKitWrapper_h__ */