1 /*
2  *                           TERMS AND CONDITIONS
3  *                                   FOR
4  *                         OPEN SOURCE CODE LICENSE
5  *                               Version 1.1
6  *
7  * Japan Registry Services Co., Ltd. ("JPRS"), a Japanese corporation
8  * having its head office at Chiyoda First Bldg. East 13F 3-8-1 Nishi-Kanda,
9  * Chiyoda-ku, Tokyo 101-0065, Japan, grants you the license for open source
10  * code specified in EXHIBIT A the "Code" subject to the following Terms and
11  * Conditions ("OSCL").
12  *
13  * 1. License Grant.
14  *   JPRS hereby grants you a worldwide, royalty-free, non-exclusive
15  *   license, subject to third party intellectual property claims:
16  *   (a) under intellectual property rights (other than patent or
17  *       trademark) licensable by JPRS to use, reproduce, modify, display,
18  *       perform, sublicense and distribute the Code (or portions thereof)
19  *       with or without modifications, and/or as part of a derivative work;
20  *       or
21  *   (b) under claims of the infringement through the making, using,
22  *       offering to sell and/or otherwise disposing the JPRS Revised Code
23  *       (or portions thereof);
24  *   (c) the licenses granted in this Section 1(a) and (b) are effective on
25  *       the date JPRS first distributes the Code to you under the terms of
26  *       this OSCL;
27  *   (d) Notwithstanding the above stated terms, no patent license is
28  *       granted:
29  *       1)  for a code that you delete from the Code;
30  *       2)  separate from the Code; or
31  *       3)  for infringements caused by:
32  *            i) modification of the Code; or
33  *           ii) combination of the Code with other software or devices.
34  *
35  * 2. Consents.
36  *   You agree that:
37  *   (a) you must include a copy of this OSCL and the notice set forth in
38  *       EXHIBIT A with every copy of the Code you distribute;
39  *   (b) you must include a copy of this OSCL and the notice set forth in
40  *       EXHIBIT A with every copy of binary form of the Code in the
41  *       documentation and/or other materials provided with the distribution;
42  *   (c) you may not offer or impose any terms on any source code version
43  *       that alters or restricts the applicable version of this OSCL or
44  *       the recipients' rights hereunder.
45  *   (d) If the terms and conditions are set forth in EXHIBIT A, you must
46  *       comply with those terms and conditions.
47  *
48  * 3. Proprietary Information.
49  *   All trademarks, service marks, patents, copyrights, trade secrets, and
50  *   other proprietary rights in or related to the Code are and will remain
51  *   the exclusive property of JPRS or its licensors, whether or not
52  *   specifically recognized or perfected under local law except specified
53  *   in this OSCL; provided however you agree and understand that the JPRS
54  *   name may not be used to endorse or promote this Code without prior
55  *   written approval of JPRS.
56  *
57  * 4. WARRANTY DISCLAIMER.
58  *   JPRS MAKES NO REPRESENTATIONS AND WARRANTIES REGARDING THE USE OF THE
59  *   CODE, NOR DOES JPRS MAKE ANY REPRESENTATIONS THAT THE CODE WILL BECOME
60  *   COMMERCIALLY AVAILABLE. JPRS, ITS AFFILIATES, AND ITS SUPPLIERS DO NOT
61  *   WARRANT OR REPRESENT THAT THE CODE IS FREE OF ERRORS OR THAT THE CODE
62  *   IS SUITABLE FOR TRANSLATION AND/OR LOCALIZATION. THE CODE IS PROVIDED
63  *   ON AN "AS IS" BASIS AND JPRS AND ITS SUPPLIERS HAVE NO OBLIGATION TO
64  *   CORRECT ERRORS OR TO SUPPORT THE CODE UNDER THIS OSCL FOR ANY REASON.
65  *   TO THE FULL EXTENT PERMITTED BY LAW, ALL OBLIGATIONS ARE HEREBY
66  *   EXCLUDED WHETHER EXPRESS, STATUTORY OR IMPLIED UNDER LAW, COURSE OF
67  *   DEALING, CUSTOM, TRADE USAGE, ORAL OR WRITTEN STATEMENT OR OTHERWISE,
68  *   INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY
69  *   OR FITNESS FOR A PARTICULAR PURPOSE CONCERNING THE CODE.
70  *
71  * 5. NO LIABILITY.
72  *   UNDER NO CIRCUMSTANCES SHALL JPRS AND/OR ITS AFFILIATES, LICENSORS, OR
73  *   REPRESENTATIVES BE LIABLE FOR ANY DAMAGES INCLUDING BUT NOT LIMITED TO
74  *   CONSEQUENTIAL, INDIRECT, SPECIAL, PUNITIVE OR INCIDENTAL DAMAGES,
75  *   WHETHER FORESEEABLE OR UNFORESEEABLE, BASED ON YOUR CLAIMS, INCLUDING,
76  *   BUT NOT LIMITED TO, CLAIMS FOR LOSS OF DATA, GOODWILL, PROFITS, USE OF
77  *   MONEY, INTERRUPTION IN USE OR AVAILABILITY OF DATA, STOPPAGE, IMPLIED
78  *   WARRANTY, BREACH OF CONTRACT, MISREPRESENTATION, NEGLIGENCE, STRICT
79  *   LIABILITY IN TORT, OR OTHERWISE.
80  *
81  * 6. Indemnification.
82  *   You hereby agree to indemnify, defend, and hold harmless JPRS for any
83  *   liability incurred by JRPS due to your terms of warranty, support,
84  *   indemnity, or liability offered by you to any third party.
85  *
86  * 7. Termination.
87  * 7.1 This OSCL shall be automatically terminated in the events that:
88  *   (a) You fail to comply with the terms herein and fail to cure such
89  *       breach within 30 days of becoming aware of the breach;
90  *   (b) You initiate patent or copyright infringement litigation against
91  *       any party (including a cross-claim or counterclaim in a lawsuit)
92  *       alleging that the Code constitutes a direct or indirect patent or
93  *       copyright infringement, in such case, this OSCL to you shall
94  *       terminate as of the date such litigation is filed;
95  * 7.2 In the event of termination under Sections 7.1(a) or 7.1(b) above,
96  *     all end user license agreements (excluding distributors and
97  *     resellers) which have been validly granted by You or any distributor
98  *     hereunder prior to termination shall survive termination.
99  *
100  *
101  * 8. General.
102  *   This OSCL shall be governed by, and construed and enforced in
103  *   accordance with, the laws of Japan. Any litigation or arbitration
104  *   between the parties shall be conducted exclusively in Tokyo, Japan
105  *   except written consent of JPRS provides other venue.
106  *
107  *
108  *                                EXHIBIT A
109  *
110  * The original open source code of idnkit-2 is idnkit-1.0 developed and
111  * conceived by Japan Network Information Center ("JPNIC"), a Japanese
112  * association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
113  * Chiyoda-ku, Tokyo 101-0047, Japan, and JPRS modifies above original code
114  * under following Terms and Conditions set forth by JPNIC.
115  *
116  *                                  JPNIC
117  *
118  * Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved.
119  *
120  * By using this file, you agree to the terms and conditions set forth bellow.
121  *
122  *                       LICENSE TERMS AND CONDITIONS
123  *
124  * The following License Terms and Conditions apply, unless a different
125  * license is obtained from Japan Network Information Center ("JPNIC"),
126  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
127  * Chiyoda-ku, Tokyo 101-0047, Japan.
128  *
129  * 1. Use, Modification and Redistribution (including distribution of any
130  *    modified or derived work) in source and/or binary forms is permitted
131  *    under this License Terms and Conditions.
132  *
133  * 2. Redistribution of source code must retain the copyright notices as they
134  *    appear in each source code file, this License Terms and Conditions.
135  *
136  * 3. Redistribution in binary form must reproduce the Copyright Notice,
137  *    this License Terms and Conditions, in the documentation and/or other
138  *    materials provided with the distribution. For the purposes of binary
139  *    distribution the "Copyright Notice" refers to the following language:
140  *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
141  *
142  * 4. The name of JPNIC may not be used to endorse or promote products
143  *    derived from this Software without specific prior written approval of
144  *    JPNIC.
145  *
146  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
147  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
148  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
149  *    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
150  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
151  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
152  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
153  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
154  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
155  *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
156  *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
157  *
158  *
159  *                        JPRS Public License Notice
160  *                                   For
161  *                                idnkit-2.
162  *
163  * The contents of this file are subject to the Terms and Conditions for
164  * the Open Source Code License (the "OSCL"). You may not use this file
165  * except in compliance with above terms and conditions. A copy of the OSCL
166  * is available at <http://jprs.co.jp/idn/>.
167  * The JPRS Revised Code is idnkit-2.
168  * The Initial Developer of the JPRS Revised Code is Japan Network
169  * Information Center ("JPNIC"), a Japanese association,
170  * Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda, Chiyoda-ku, Tokyo
171  * 101-0047, Japan.
172  * "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
173  * "Copyright (c) 2010-2012 Japan Registry Services Co., Ltd.  All rights reserved."
174  * Contributor(s): ______________________________________.
175  *
176  * If you wish to allow use of your version of this file only under the
177  * above License(s) and not to allow others to use your version of this
178  * file, please indicate your decision by deleting the relevant provisions
179  * above and replacing them with the notice and other provisions required
180  * by the above License(s). If you do not delete the relevant provisions,
181  * a recipient may use your version of this file under either the above
182  * License(s).
183  */
184 
185 /*
186  * Low level API module of libidnkit.
187  *
188  * All the functions provided by this module requires a configuration
189  * context of type 'idn_resconf_t' as an argument. The context holds
190  * information described in the configuration file (idn.conf).
191  * See 'resconf' module for details.
192  */
193 
194 #ifndef IDN_RES_H
195 #define IDN_RES_H 1
196 
197 #ifdef __cplusplus
198 extern "C" {
199 #endif
200 
201 #include <stddef.h>
202 #include <idn/result.h>
203 #include <idn/export.h>
204 #include <idn/resconf.h>
205 
206 /*
207  * Actions.
208  */
209 typedef unsigned long idn_action_t;
210 
211 #define IDN_UNICODECONV   0x00000001UL /* Local encoding -> UTF-8 */
212 #define IDN_MAP           0x00000002UL /* Mappings */
213 #define IDN_ASCLOWER      0x00000004UL /* ASCII Lowercase */
214 #define IDN_RTCONV        0x00000008UL /* Punycode -> UTF-8 for RTCHECK */
215 #define IDN_PROHCHECK     0x00000010UL /* Prohibited code point check */
216 #define IDN_UNASCHECK     0x00000020UL /* Unassigned code point check */
217 #define IDN_NFCCHECK      0x00000040UL /* NFC validation check */
218 #define IDN_PREFCHECK     0x00000080UL /* ACE prefix check */
219 #define IDN_HYPHCHECK     0x00000100UL /* Hyphen check */
220 #define IDN_COMBCHECK     0x00000200UL /* Combining character check */
221 #define IDN_CTXJCHECK     0x00000400UL /* CONTEXTJ check */
222 #define IDN_CTXOCHECK     0x00000800UL /* CONTEXTO check for registration */
223 #define IDN_CTXOLITECHECK 0x00001000UL /* CONTEXTO check for lookup */
224 #define IDN_BIDICHECK     0x00002000UL /* Bidi check */
225 #define IDN_LOCALCHECK    0x00004000UL /* Local check */
226 #define IDN_IDNCONV       0x00008000UL /* UTF-8 <-> Punycode */
227 #define IDN_LENCHECK      0x00010000UL /* Label length check */
228 #define IDN_RTCHECK       0x00020000UL /* Round trip check */
229 #define IDN_LOCALCONV     0x00040000UL /* UTF-8 -> Local encoding */
230 #define IDN_UNDOIFERR     0x40000000UL /* Option: undo if an error occurs */
231 #define IDN_LITEFORCEUTF8 0x80000000UL /* libidnkitlite option: force to con-
232 					* -sider the local encoding is UTF-8 */
233 
234 /*
235  * Combined Actions.
236  */
237 #define IDN_ENCODE_REGIST \
238 	(IDN_UNICODECONV | IDN_MAP | IDN_ASCLOWER | IDN_RTCONV | \
239 	IDN_PROHCHECK | IDN_UNASCHECK | IDN_NFCCHECK | IDN_PREFCHECK | \
240 	IDN_HYPHCHECK | IDN_COMBCHECK | IDN_CTXJCHECK | IDN_CTXOCHECK | \
241 	IDN_BIDICHECK | IDN_IDNCONV | IDN_LENCHECK | IDN_RTCHECK | \
242 	IDN_LITEFORCEUTF8)
243 #define IDN_ENCODE_LOOKUP \
244 	(IDN_UNICODECONV | IDN_MAP | IDN_ASCLOWER | IDN_RTCONV | \
245 	IDN_PROHCHECK | IDN_UNASCHECK | IDN_NFCCHECK | IDN_PREFCHECK | \
246 	IDN_COMBCHECK | IDN_CTXJCHECK | IDN_CTXOLITECHECK | \
247 	IDN_BIDICHECK | IDN_IDNCONV | IDN_LENCHECK | IDN_RTCHECK | \
248 	IDN_LITEFORCEUTF8)
249 #define IDN_DECODE_REGIST \
250 	(IDN_UNICODECONV | IDN_MAP | IDN_ASCLOWER | IDN_IDNCONV | \
251 	IDN_PROHCHECK | IDN_UNASCHECK | IDN_NFCCHECK | IDN_PREFCHECK | \
252 	IDN_HYPHCHECK | IDN_COMBCHECK | IDN_CTXJCHECK | IDN_CTXOCHECK | \
253 	IDN_BIDICHECK | IDN_RTCHECK | IDN_LOCALCONV | IDN_LITEFORCEUTF8)
254 #define IDN_DECODE_LOOKUP \
255 	(IDN_UNICODECONV | IDN_MAP | IDN_ASCLOWER | IDN_IDNCONV | \
256 	IDN_PROHCHECK | IDN_UNASCHECK | IDN_NFCCHECK | IDN_PREFCHECK | \
257 	IDN_COMBCHECK | IDN_CTXJCHECK | IDN_CTXOLITECHECK | \
258 	IDN_BIDICHECK | IDN_RTCHECK | IDN_LOCALCONV | IDN_LITEFORCEUTF8)
259 
260 #define IDN_COMPARE_REGIST IDN_ENCODE_REGIST
261 #define IDN_COMPARE_LOOKUP IDN_ENCODE_LOOKUP
262 #define IDN_CHECK_REGIST   IDN_ENCODE_REGIST
263 #define IDN_CHECK_LOOKUP   IDN_ENCODE_LOOKUP
264 
265 /*
266  * These macros are provided for backward compatibility to idnkit 1.x.
267  */
268 #define IDN_ENCODE_STORED  IDN_ENCODE_REGIST
269 #define IDN_ENCODE_QUERY   IDN_ENCODE_LOOKUP
270 #define IDN_ENCODE_APP     IDN_ENCODE_LOOKUP
271 #define IDN_DECODE_STORED  IDN_DECODE_REGIST
272 #define IDN_DECODE_QUERY   IDN_DECODE_LOOKUP
273 #define IDN_DECODE_APP     IDN_DECODE_LOOKUP
274 
275 /*
276  * Encode an internationalized domain name.
277  *
278  * The function converts a domain name 'from' and writes the result on 'to',
279  * at most 'tolen' bytes. Note that 'from' must be terminated by NUL, and
280  * 'tolen' includes room for a NUL character.
281  *
282  * The argument 'actions' specifies which steps in the entire encoding
283  * process should be performed. The following list shows action names
284  * corresponding with steps of the encoding process. The function
285  * performs the steps in that order.
286  *
287  *    1. IDN_UNICODECONV
288  *       Convert a domain name from local encoding (e.g. ISO-8859-1) to UTF-8.
289  *    2. IDN_MAP
290  *       Perform mappings (NFC, Lowercase conversion, etc.).
291  *    3. IDN_ASCLOWER
292  *       Convert ASCII uppercase letters (A..Z) to lowercase (a..z).
293  *    4. IDN_RTCONV
294  *       Convert A-labels to U-labels.
295  *    5. IDN_PROHCHECK
296  *       Check prohibited code points.
297  *    6. IDN_UNASCHECK
298  *       Check unassigned code points.
299  *    7. IDN_NFCCHECK
300  *       Check labels are in NFC.
301  *    8. IDN_PREFCHECK
302  *       Check labels containing "--" in the 3rd and 4th characters.
303  *    9. IDN_HYPHCHECK
304  *       Check labels beginning/ending with "-".
305  *   10. IDN_COMBCHECK
306  *       Check labels beginning with a combining mark.
307  *   11. IDN_CTXJCHECK
308  *       Check CONTEXTJ code points.
309  *  12a. IDN_CTXOCHECK
310  *       Check CONTEXTO code points for the registration protocol.
311  *  12b. IDN_CTXOLITECHECK
312  *       Check CONTEXTO code points for the lookup protocol.
313  *   13. IDN_BIDICHECK
314  *       Check requirements specified in [IDNA2008-BIDI].
315  *   14. IDN_LOCALCHECK
316  *       Perform local check (optional).
317  *   15. IDN_IDNCONV
318  *       Convert labels in UTF-8 to Punycode.
319  *   16. IDN_LENCHECK
320  *       Check length of each label.
321  *   17. IDN_RTCHECK
322  *       Perform round trip check for each label.
323  *
324  * Between the step 2 and 3, the domain name is split into labels.
325  * The step 3 through 17 are applied to each label. After the step 17,
326  * labels are joined with a separator '.'.
327  *
328  * A value of bitwise-OR of some actions can be specified, like:
329  *
330  *   result = idn_res_encodename(ctx, IDN_UNICODECONV | IDN_MAP,
331  *                               from, to, tolen);
332  *
333  * Also the following actions are provided for convenience:
334  *
335  *   IDN_ENCODE_REGIST
336  *      Encode a domain name with IDNA2008 registration protocol.
337  *      libidnkit performs the step 1..11, 12a, 13 and 15..17.
338  *      libidnkitlite performs the step 2..11, 12a, 13 and 15..17.
339  *
340  *   IDN_ENCODE_LOOKUP
341  *      Encode a domain name with IDNA2008 lookup protocol.
342  *      libidnkit performs the step 1..8, 10, 11, 12b, 13 and 15..17.
343  *      libidnkitlite performs the step 2..8, 10, 11, 12b, 13 and 15..17.
344  *
345  * The following action is not an actual step of the encoding process,
346  * but it can be specified with other actions described above.
347  *
348  *   IDN_UNDOIFERR	-- If any step fails, the original input name is
349  *                         returned.
350  *
351  * If no flags are specified, the function just copies 'from' to 'to'.
352  *
353  * Returns:
354  *   idn_success            -- Ok.
355  *   idn_invalid_action	    -- Invalid action flag specified.
356  *   idn_invalid_encoding   -- The given string has invalid byte sequence.
357  *   idn_buffer_overflow    -- 'tolen' is too small.
358  *   idn_nomemory           -- malloc() failed.
359  *   idn_nomapping          -- At IDN_LOCALCONV or IDN_UNICODECONV, the
360  *                             corresponding character doesn't exist in
361  *                             the destination encoding.
362  *   idn_prohcheck_error    -- IDN_PROHCHECK failed.
363  *   idn_unascheck_error    -- IDN_UNASCHECK failed.
364  *   idn_nfccheck_error     -- IDN_NFCCHECK failed.
365  *   idn_prefcheck_error    -- IDN_PREFCHECK failed.
366  *   idn_hyphcheck_error    -- IDN_HYPHCHECK failed.
367  *   idn_combcheck_error    -- IDN_COMBCHECK failed.
368  *   idn_ctxjcheck_error    -- IDN_CTXJCHECK failed.
369  *   idn_ctxocheck_error    -- IDN_CTXOCHECK or IDN_CTXOLITECHECK failed.
370  *   idn_bidicheck_error    -- IDN_BIDICHECK failed.
371  *   idn_localcheck_error   -- IDN_LOCALCHECK failed.
372  *   idn_lencheck_error     -- IDN_LENCHECK failed.
373  *   idn_rtcheck_error      -- IDN_RTCHECK failed.
374  */
375 IDN_EXPORT idn_result_t
376 idn_res_encodename(idn_resconf_t ctx, idn_action_t actions, const char *from,
377 		   char *to, size_t tolen);
378 
379 /*
380  * Decode an internationalized domain name.
381  *
382  * The function converts a domain name 'from' and writes the result on 'to',
383  * at most 'tolen' bytes. Note that 'from' must be terminated by NUL, and
384  * 'tolen' includes room for a NUL character.
385  *
386  * The argument 'actions' specifies which steps in the entire decoding
387  * process should be performed. The following list shows action names
388  * corresponding with steps of the decoding process. The function
389  * performs the steps in that order.
390  *
391  *    1. IDN_UNICODECONV
392  *       Convert a domain name from local encoding (e.g. ISO-8859-1) to UTF-8.
393  *    2. IDN_MAP
394  *       Perform mappings (NFC, Lowercase conversion, etc.).
395  *    3. IDN_ASCLOWER
396  *       Convert ASCII uppercase letters (A..Z) to lowercase (a..z).
397  *    4. IDN_IDNCONV
398  *       Convert A-labels to U-labels.
399  *    5. IDN_PROHCHECK
400  *       Check prohibited code points.
401  *    6. IDN_UNASCHECK
402  *       Check unassigned code points.
403  *    7. IDN_NFCCHECK
404  *       Check labels are in NFC.
405  *    8. IDN_PREFCHECK
406  *       Check labels containing "--" in the 3rd and 4th characters.
407  *    9. IDN_HYPHCHECK
408  *       Check labels beginning/ending with "-".
409  *   10. IDN_COMBCHECK
410  *       Check labels beginning with a combining mark.
411  *   11. IDN_CTXJCHECK
412  *       Check CONTEXTJ code points.
413  *  12a. IDN_CTXOCHECK
414  *       Check CONTEXTO code points for the registration protocol.
415  *  12b. IDN_CTXOLITECHECK
416  *       Check CONTEXTO code points for the lookup protocol.
417  *   13. IDN_BIDICHECK
418  *       Check requirements specified in [IDNA2008-BIDI].
419  *   14. IDN_LOCALCHECK
420  *       Perform local check (optional).
421  *   15. IDN_RTCHECK
422  *       Perform round trip check for each label.
423  *   16. IDN_LOCALCONV
424  *       Convert a domain name from UTF-8 to local encoding (e.g. ISO-8859-1).
425  *
426  * Between the step 2 and 3, the domain name is split into labels.
427  * The step 3 through 15 are applied to each label. After the step 15,
428  * labels are joined with a separator '.'.
429  *
430  * A value of bitwise-OR of some actions can be specified, like:
431  *
432  *   result = idn_res_decodename(ctx, IDN_IDNCONV | IDN_LOCALCONV,
433  *                               from, to, tolen);
434  *
435  * Also the following actions are provided for convenience:
436  *
437  *   IDN_DECODE_REGIST
438  *      Decode a domain name with IDNA2008 registration protocol.
439  *      libidnkit performs the step 1..11, 12a, 13, 15 and 16.
440  *      libidnkitlite performs the step 2..11, 12a, 13 and 15.
441  *
442  *   IDN_DECODE_LOOKUP
443  *      Decode a domain name with IDNA2008 lookup protocol.
444  *      libidnkit performs the step 1..8, 10, 11, 12b, 13, 15 and 16.
445  *      libidnkitlite performs the step 2..8, 10, 11, 12b, 13 and 15.
446  *
447  *
448  * The following action is not an actual step of the decoding process,
449  * but it can be specified with other actions described above.
450  *
451  *   IDN_UNDOIFERR	-- If any step fails, the original input name is
452  *                         returned.
453  *
454  * If no flags are specified, the function just copies 'from' to 'to'.
455  *
456  * Returns:
457  *   idn_success            -- Ok.
458  *   idn_invalid_action	    -- Invalid action flag specified.
459  *   idn_invalid_encoding   -- The given string has invalid byte sequence.
460  *   idn_buffer_overflow    -- 'tolen' is too small.
461  *   idn_nomemory           -- malloc() failed.
462  *   idn_nomapping          -- At IDN_LOCALCONV or IDN_UNICODECONV, the
463  *                             corresponding character doesn't exist in
464  *                             the destination encoding.
465  *   idn_prohcheck_error    -- IDN_PROHCHECK failed.
466  *   idn_unascheck_error    -- IDN_UNASCHECK failed.
467  *   idn_nfccheck_error     -- IDN_NFCCHECK failed.
468  *   idn_prefcheck_error    -- IDN_PREFCHECK failed.
469  *   idn_hyphcheck_error    -- IDN_HYPHCHECK failed.
470  *   idn_combcheck_error    -- IDN_COMBCHECK failed.
471  *   idn_ctxjcheck_error    -- IDN_CTXJCHECK failed.
472  *   idn_ctxocheck_error    -- IDN_CTXOCHECK or IDN_CTXOLITECHECK failed.
473  *   idn_bidicheck_error    -- IDN_BIDICHECK failed.
474  *   idn_localcheck_error   -- IDN_LOCALCHECK failed.
475  */
476 IDN_EXPORT idn_result_t
477 idn_res_decodename(idn_resconf_t ctx, idn_action_t actions, const char *from,
478 		   char *to, size_t tolen);
479 
480 /*
481  * Decode an internationalized domain name with auxiliary encoding
482  * support.
483  *
484  * The function works the same as idn_res_decodename(), but an encoding
485  * conversion from 'auxencoding' to UTF-8 is performed prior to the actual
486  * decode process (see idn_res_decodename() above).
487  *
488  * If 'auxencoding' is NULL, 'from' is treated as UTF-8.
489  */
490 IDN_EXPORT idn_result_t
491 idn_res_decodename2(idn_resconf_t ctx, idn_action_t actions, const char *from,
492 		    char *to, size_t tolen, const char *auxencoding);
493 
494 /*
495  * Compare two domain names.
496  *
497  * The functions encodes domain names 'name1' and 'name2' as
498  * idn_res_encodename() does, and then compares them.
499  * If they are equivalent, it returns 'idn_success'. Otherwise,
500  * it returns 'idn_neq'. When an error occurs in the encoding process,
501  * the function returns the correspoinding error code
502  * (see idn_res_encodename() above).
503  *
504  * Returns:
505  *   idn_success            -- 'name1' and 'name2' are equivalent.
506  *   idn_neq                -- 'name1' and 'name2' are different.
507  *   (other error codes)    -- See idn_res_encodename().
508  */
509 IDN_EXPORT idn_result_t
510 idn_res_comparenames(idn_resconf_t ctx, idn_action_t actions,
511 		     const char *name1, const char *name2);
512 
513 /*
514  * Compare two domain names.
515  *
516  * The function works the same as idn_res_comparenames(), but it performs
517  * 'actions1' when it encodes 'name1' and it perfomrs 'actions2' when
518  * it encodes 'name2' respectively.
519  */
520 IDN_EXPORT idn_result_t
521 idn_res_comparenames2(idn_resconf_t ctx,
522 		      idn_action_t actions1, const char *name1,
523 		      idn_action_t actions2, const char *name2);
524 
525 /*
526  * Check a domain name.
527  *
528  * The function internally creates a copy of 'name', performs
529  * the encoding process 'actions' for it, and returns its error code
530  * as idn_res_encodename() does.
531  */
532 IDN_EXPORT idn_result_t
533 idn_res_checkname(idn_resconf_t ctx, idn_action_t actions, const char *name);
534 
535 /*
536  * The function is provided for backward compatibility to idnkit 1.x.
537  */
538 IDN_EXPORT void
539 idn_res_enable(int on_off);
540 
541 #ifdef __cplusplus
542 }
543 #endif
544 
545 #endif /* IDN_RES_H */
546