ignore some files
[tridge/bind9.git] / contrib / idn / idnkit-1.0-src / include / idn / mapselector.h
1 /* $Id: mapselector.h,v 1.1.1.1 2003/06/04 00:25:39 marka Exp $ */
2 /*
3  * Copyright (c) 2001 Japan Network Information Center.  All rights reserved.
4  *  
5  * By using this file, you agree to the terms and conditions set forth bellow.
6  * 
7  *                      LICENSE TERMS AND CONDITIONS 
8  * 
9  * The following License Terms and Conditions apply, unless a different
10  * license is obtained from Japan Network Information Center ("JPNIC"),
11  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
12  * Chiyoda-ku, Tokyo 101-0047, Japan.
13  * 
14  * 1. Use, Modification and Redistribution (including distribution of any
15  *    modified or derived work) in source and/or binary forms is permitted
16  *    under this License Terms and Conditions.
17  * 
18  * 2. Redistribution of source code must retain the copyright notices as they
19  *    appear in each source code file, this License Terms and Conditions.
20  * 
21  * 3. Redistribution in binary form must reproduce the Copyright Notice,
22  *    this License Terms and Conditions, in the documentation and/or other
23  *    materials provided with the distribution.  For the purposes of binary
24  *    distribution the "Copyright Notice" refers to the following language:
25  *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
26  * 
27  * 4. The name of JPNIC may not be used to endorse or promote products
28  *    derived from this Software without specific prior written approval of
29  *    JPNIC.
30  * 
31  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
32  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
34  *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
35  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40  *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41  *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #ifndef IDN_MAPSELECTOR_H
45 #define IDN_MAPSELECTOR_H 1
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /*
52  * Map selector.
53  *
54  * Perfom mapping the specified domain name according with the TLD
55  * of the donmain name.
56  */
57
58 #include <idn/export.h>
59 #include <idn/result.h>
60 #include <idn/mapper.h>
61
62 /*
63  * Special TLDs for map selection.
64  */
65 #define IDN_MAPSELECTOR_NOTLD           "-"
66 #define IDN_MAPSELECTOR_DEFAULTTLD      "."
67
68 IDN_EXPORT const unsigned long *
69 idn_mapselector_getnotld(void);
70
71 IDN_EXPORT const unsigned long *
72 idn_mapselector_getdefaulttld(void);
73
74 /*
75  * Mapselector object type.
76  */
77 typedef struct idn_mapselector *idn_mapselector_t;
78
79 /*
80  * Initialize module.  Must be called before any other calls of
81  * the functions of this module.
82  *
83  * Returns:
84  *      idn_success             -- ok.
85  *      idn_nomemory            -- malloc failed.
86  */
87 IDN_EXPORT idn_result_t
88 idn_mapselector_initialize(void);
89
90 /*
91  * Create a mapselector context.
92  *
93  * Returns:
94  *      idn_success             -- ok.
95  *      idn_nomemory            -- malloc failed.
96  */
97 IDN_EXPORT idn_result_t
98 idn_mapselector_create(idn_mapselector_t *ctxp);
99
100 /*
101  * Decrement reference count of the mapselector `ctx' created by
102  * 'idn_mapselector_create', if it is still refered by another object.
103  * Otherwise, release all the memory allocated to the mapselector.
104  */
105 IDN_EXPORT void
106 idn_mapselector_destroy(idn_mapselector_t ctx);
107
108 /*
109  * Increment reference count of the mapselector `ctx' created by
110  * 'idn_mapselector_create'.
111  */
112 IDN_EXPORT void
113 idn_mapselector_incrref(idn_mapselector_t ctx);
114
115 /*
116  * Return the mapper for `tld' registered in `ctx', or return NULL if
117  * mapper for `tld' is not registered.
118  */
119 IDN_EXPORT idn_mapper_t
120 idn_mapselector_mapper(idn_mapselector_t ctx, const char *tld);
121
122 /*
123  * Add mapping scheme `name' to the mapper for `tld' to the mapselector
124  * context `ctx'.  If no mapper for `TLD' has not been registered, the
125  * function creates a new mapper for `tld', and then adds the given mapping
126  * scheme to the mapper.  Otherwise,  it adds the scheme to the mapper for
127  * TLD registered in `ctx'.
128  * 
129  * Returns:
130  *      idn_success             -- ok.
131  *      idn_invalid_name        -- the given tld or name is not valid.
132  *      idn_nomemory            -- malloc failed.
133  */
134 IDN_EXPORT idn_result_t
135 idn_mapselector_add(idn_mapselector_t ctx, const char *tld, const char *name);
136
137 IDN_EXPORT idn_result_t
138 idn_mapselector_addall(idn_mapselector_t ctx, const char *tld,
139                        const char **names, int nnames);
140
141 /*
142  * Map an UCS4 string with the mapper for TLD of the domain name.
143  * If there is no mapper suitable for the domain name, the function
144  * simply copies the doman name.
145  *
146  * Returns:
147  *      idn_success             -- ok.
148  *      idn_nomemory            -- malloc failed.
149  *      idn_buffer_overflow     -- output buffer is too small.
150  *      idn_invalid_name        -- the given tld is not valid.
151  */
152 IDN_EXPORT idn_result_t
153 idn_mapselector_map(idn_mapselector_t ctx, const unsigned long *from,
154                     const char *tld, unsigned long *to, size_t tolen);
155
156 IDN_EXPORT idn_result_t
157 idn_mapselector_map2(idn_mapselector_t ctx, const unsigned long *from,
158                      const unsigned long *tld, unsigned long *to,
159                      size_t tolen);
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif /* IDN_MAPSELECTOR_H */