1 /* $Id: mapselector.h,v 1.1.1.1 2003/06/04 00:25:39 marka Exp $ */
3 * Copyright (c) 2001 Japan Network Information Center. All rights reserved.
5 * By using this file, you agree to the terms and conditions set forth bellow.
7 * LICENSE TERMS AND CONDITIONS
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.
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.
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.
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."
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
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.
44 #ifndef IDN_MAPSELECTOR_H
45 #define IDN_MAPSELECTOR_H 1
54 * Perfom mapping the specified domain name according with the TLD
55 * of the donmain name.
58 #include <idn/export.h>
59 #include <idn/result.h>
60 #include <idn/mapper.h>
63 * Special TLDs for map selection.
65 #define IDN_MAPSELECTOR_NOTLD "-"
66 #define IDN_MAPSELECTOR_DEFAULTTLD "."
68 IDN_EXPORT const unsigned long *
69 idn_mapselector_getnotld(void);
71 IDN_EXPORT const unsigned long *
72 idn_mapselector_getdefaulttld(void);
75 * Mapselector object type.
77 typedef struct idn_mapselector *idn_mapselector_t;
80 * Initialize module. Must be called before any other calls of
81 * the functions of this module.
85 * idn_nomemory -- malloc failed.
87 IDN_EXPORT idn_result_t
88 idn_mapselector_initialize(void);
91 * Create a mapselector context.
95 * idn_nomemory -- malloc failed.
97 IDN_EXPORT idn_result_t
98 idn_mapselector_create(idn_mapselector_t *ctxp);
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.
106 idn_mapselector_destroy(idn_mapselector_t ctx);
109 * Increment reference count of the mapselector `ctx' created by
110 * 'idn_mapselector_create'.
113 idn_mapselector_incrref(idn_mapselector_t ctx);
116 * Return the mapper for `tld' registered in `ctx', or return NULL if
117 * mapper for `tld' is not registered.
119 IDN_EXPORT idn_mapper_t
120 idn_mapselector_mapper(idn_mapselector_t ctx, const char *tld);
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'.
131 * idn_invalid_name -- the given tld or name is not valid.
132 * idn_nomemory -- malloc failed.
134 IDN_EXPORT idn_result_t
135 idn_mapselector_add(idn_mapselector_t ctx, const char *tld, const char *name);
137 IDN_EXPORT idn_result_t
138 idn_mapselector_addall(idn_mapselector_t ctx, const char *tld,
139 const char **names, int nnames);
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.
148 * idn_nomemory -- malloc failed.
149 * idn_buffer_overflow -- output buffer is too small.
150 * idn_invalid_name -- the given tld is not valid.
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);
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,
165 #endif /* IDN_MAPSELECTOR_H */