1/* $Id: resconf.h,v 1.1 2003/06/04 00:25:41 marka Exp $ */ 2/* 3 * Copyright (c) 2000 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_RESCONF_H 45#define IDN_RESCONF_H 1 46 47#ifdef __cplusplus 48extern "C" { 49#endif 50 51/* 52 * IDN resolver configuration. 53 */ 54 55#include <idn/export.h> 56#include <idn/result.h> 57#include <idn/converter.h> 58#include <idn/normalizer.h> 59#include <idn/checker.h> 60#include <idn/mapper.h> 61#include <idn/mapselector.h> 62#include <idn/delimitermap.h> 63 64/* 65 * Configuration type (opaque). 66 */ 67typedef struct idn_resconf *idn_resconf_t; 68 69/* 70 * Initialize. 71 * 72 * Initialize this module and underlying ones. Must be called before 73 * any other functions of this module. 74 * 75 * Returns: 76 * idn_success -- ok. 77 * idn_nomemory -- malloc failed. 78 */ 79IDN_EXPORT idn_result_t 80idn_resconf_initialize(void); 81 82/* 83 * Create a configuration context. 84 * 85 * Create an empty context and store it in '*ctxp'. 86 * 87 * Returns: 88 * idn_success -- ok. 89 * idn_nomemory -- malloc failed. 90 */ 91IDN_EXPORT idn_result_t 92idn_resconf_create(idn_resconf_t *ctxp); 93 94/* 95 * Destroy the configuration context. 96 * 97 * Destroy the configuration context created by 'idn_resconf_create', 98 * and release memory for it. 99 */ 100IDN_EXPORT void 101idn_resconf_destroy(idn_resconf_t ctx); 102 103/* 104 * Increment reference count of the context created by 'idn_resconf_create'. 105 */ 106IDN_EXPORT void 107idn_resconf_incrref(idn_resconf_t ctx); 108 109/* 110 * Set default configurations to resconf context. 111 * 112 * "default configurations" means current nameprep and IDN encoding 113 * which IDN standard document suggests. 114 * 115 * Warning: configurations set previously are removed. 116 * 117 * Returns: 118 * idn_success -- ok. 119 * idn_invalid_syntax -- syntax error found. 120 * idn_invalid_name -- invalid encoding/nomalization name is 121 * specified. 122 * idn_nomemory -- malloc failed. 123 */ 124IDN_EXPORT idn_result_t 125idn_resconf_setdefaults(idn_resconf_t ctx); 126 127/* 128 * Load configuration file. 129 * 130 * Parse a configuration file whose name is specified by 'file', 131 * store the result in 'ctx'. If 'file' is NULL, the default file is 132 * loaded. 133 * 134 * Returns: 135 * idn_success -- ok. 136 * idn_nofile -- couldn't open specified file. 137 * idn_invalid_syntax -- syntax error found. 138 * idn_invalid_name -- invalid encoding/nomalization name is 139 * specified. 140 * idn_nomemory -- malloc failed. 141 */ 142IDN_EXPORT idn_result_t 143idn_resconf_loadfile(idn_resconf_t ctx, const char *file); 144 145/* 146 * Get the pathname of the default configuration file. 147 * 148 * Returns: 149 * the pathname of the default configuration file. 150 */ 151IDN_EXPORT char * 152idn_resconf_defaultfile(void); 153 154/* 155 * Get an object of lower module that `ctx' holds. 156 */ 157IDN_EXPORT idn_delimitermap_t 158idn_resconf_getdelimitermap(idn_resconf_t ctx); 159 160IDN_EXPORT idn_converter_t 161idn_resconf_getidnconverter(idn_resconf_t ctx); 162 163IDN_EXPORT idn_converter_t 164idn_resconf_getauxidnconverter(idn_resconf_t ctx); 165 166IDN_EXPORT idn_converter_t 167idn_resconf_getlocalconverter(idn_resconf_t ctx); 168 169IDN_EXPORT idn_mapselector_t 170idn_resconf_getlocalmapselector(idn_resconf_t ctx); 171 172IDN_EXPORT idn_mapper_t 173idn_resconf_getmapper(idn_resconf_t ctx); 174 175IDN_EXPORT idn_normalizer_t 176idn_resconf_getnormalizer(idn_resconf_t ctx); 177 178IDN_EXPORT idn_checker_t 179idn_resconf_getprohibitchecker(idn_resconf_t ctx); 180 181IDN_EXPORT idn_checker_t 182idn_resconf_getunassignedchecker(idn_resconf_t ctx); 183 184IDN_EXPORT idn_checker_t 185idn_resconf_getbidichecker(idn_resconf_t ctx); 186 187/* 188 * Set an object of lower module to `ctx'. 189 */ 190IDN_EXPORT void 191idn_resconf_setdelimitermap(idn_resconf_t ctx, 192 idn_delimitermap_t delimiter_mapper); 193 194IDN_EXPORT void 195idn_resconf_setidnconverter(idn_resconf_t ctx, 196 idn_converter_t idn_coverter); 197 198IDN_EXPORT void 199idn_resconf_setauxidnconverter(idn_resconf_t ctx, 200 idn_converter_t aux_idn_coverter); 201 202IDN_EXPORT void 203idn_resconf_setlocalconverter(idn_resconf_t ctx, 204 idn_converter_t local_converter); 205 206IDN_EXPORT void 207idn_resconf_setlocalmapselector(idn_resconf_t ctx, 208 idn_mapselector_t map_selector); 209 210IDN_EXPORT void 211idn_resconf_setmapper(idn_resconf_t ctx, idn_mapper_t mapper); 212 213IDN_EXPORT void 214idn_resconf_setnormalizer(idn_resconf_t ctx, idn_normalizer_t normalizer); 215 216IDN_EXPORT void 217idn_resconf_setprohibitchecker(idn_resconf_t ctx, 218 idn_checker_t prohibit_checker); 219 220IDN_EXPORT void 221idn_resconf_setunassignedchecker(idn_resconf_t ctx, 222 idn_checker_t unassigned_checker); 223 224IDN_EXPORT void 225idn_resconf_setbidichecker(idn_resconf_t ctx, 226 idn_checker_t bidi_checker); 227 228/* 229 * Set name or add names to an object of lower module that `ctx' holds. 230 */ 231IDN_EXPORT idn_result_t 232idn_resconf_setidnconvertername(idn_resconf_t ctx, const char *name, 233 int flags); 234 235IDN_EXPORT idn_result_t 236idn_resconf_setauxidnconvertername(idn_resconf_t ctx, const char *name, 237 int flags); 238 239IDN_EXPORT idn_result_t 240idn_resconf_addalldelimitermapucs(idn_resconf_t ctx, unsigned long *v, int nv); 241 242IDN_EXPORT idn_result_t 243idn_resconf_setlocalconvertername(idn_resconf_t ctx, const char *name, 244 int flags); 245 246IDN_EXPORT idn_result_t 247idn_resconf_addalllocalmapselectornames(idn_resconf_t ctx, const char *tld, 248 const char **names, int nnames); 249 250IDN_EXPORT idn_result_t 251idn_resconf_addallmappernames(idn_resconf_t ctx, const char **names, 252 int nnames); 253 254IDN_EXPORT idn_result_t 255idn_resconf_addallnormalizernames(idn_resconf_t ctx, const char **names, 256 int nnames); 257 258IDN_EXPORT idn_result_t 259idn_resconf_addallprohibitcheckernames(idn_resconf_t ctx, const char **names, 260 int nnames); 261 262IDN_EXPORT idn_result_t 263idn_resconf_addallunassignedcheckernames(idn_resconf_t ctx, const char **names, 264 int nnames); 265 266IDN_EXPORT idn_result_t 267idn_resconf_addallbidicheckernames(idn_resconf_t ctx, const char **names, 268 int nnames); 269 270IDN_EXPORT idn_result_t 271idn_resconf_setnameprepversion(idn_resconf_t ctx, const char *version); 272 273/* 274 * These macros are provided for backward compatibility to mDNkit 2.1 275 * and older. 276 */ 277IDN_EXPORT void 278idn_resconf_setalternateconverter(idn_resconf_t ctx, 279 idn_converter_t alternate_converter); 280 281IDN_EXPORT idn_result_t 282idn_resconf_setalternateconvertername(idn_resconf_t ctx, const char *name, 283 int flags); 284 285IDN_EXPORT idn_converter_t 286idn_resconf_getalternateconverter(idn_resconf_t ctx); 287 288 289/* 290 * These macros are provided for backward compatibility to idnkit 1.x. 291 */ 292#define idn_resconf_localconverter(ctx) \ 293 idn_resconf_getlocalconverter(ctx) 294 295#define idn_resconf_idnconverter(ctx) \ 296 idn_resconf_getidnconverter(ctx) 297 298#define idn_resconf_alternateconverter(ctx) \ 299 idn_resconf_getalternateconverter(ctx) 300 301#define idn_resconf_normalizer(ctx) \ 302 idn_resconf_getnormalizer(ctx) 303 304#define idn_resconf_mapper(ctx) \ 305 idn_resconf_getmapper(ctx) 306 307#define idn_resconf_delimitermap(ctx) \ 308 idn_resconf_getdelimitermap(ctx) 309 310#define idn_resconf_localmapselector(ctx) \ 311 idn_resconf_getlocalmapselector(ctx) 312 313#define idn_resconf_prohibitchecker(ctx) \ 314 idn_resconf_getprohibitchecker(ctx) 315 316#define idn_resconf_unassignedchecker(ctx) \ 317 idn_resconf_getunassignedchecker(ctx) 318 319#ifdef __cplusplus 320} 321#endif 322 323#endif /* IDN_RESCONF_H */ 324