1/* $Id: nameprep.h,v 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_NAMEPREP_H 45#define IDN_NAMEPREP_H 1 46 47#ifdef __cplusplus 48extern "C" { 49#endif 50 51/* 52 * Perform NAMEPREP (mapping, prohibited/unassigned checking). 53 */ 54 55#include <idn/export.h> 56#include <idn/result.h> 57 58/* 59 * BIDI type codes. 60 */ 61typedef enum { 62 idn_biditype_r_al, 63 idn_biditype_l, 64 idn_biditype_others 65} idn_biditype_t; 66 67/* 68 * A Handle for nameprep operations. 69 */ 70typedef struct idn_nameprep *idn_nameprep_t; 71 72 73/* 74 * The latest version of nameprep. 75 */ 76#define IDN_NAMEPREP_CURRENT "RFC3491" 77 78/* 79 * Create a handle for nameprep operations. 80 * The handle is stored in '*handlep', which is used other functions 81 * in this module. 82 * The version of the NAMEPREP specification can be specified with 83 * 'version' parameter. If 'version' is NULL, the latest version 84 * is used. 85 * 86 * Returns: 87 * idn_success -- ok. 88 * idn_notfound -- specified version not found. 89 */ 90IDN_EXPORT idn_result_t 91idn_nameprep_create(const char *version, idn_nameprep_t *handlep); 92 93/* 94 * Close a handle, which was created by 'idn_nameprep_create'. 95 */ 96IDN_EXPORT void 97idn_nameprep_destroy(idn_nameprep_t handle); 98 99/* 100 * Perform character mapping on an UCS4 string specified by 'from', and 101 * store the result into 'to', whose length is specified by 'tolen'. 102 * 103 * Returns: 104 * idn_success -- ok. 105 * idn_buffer_overflow -- result buffer is too small. 106 */ 107IDN_EXPORT idn_result_t 108idn_nameprep_map(idn_nameprep_t handle, const unsigned long *from, 109 unsigned long *to, size_t tolen); 110 111/* 112 * Check if an UCS4 string 'str' contains any prohibited characters specified 113 * by the draft. If found, the pointer to the first such character is stored 114 * into '*found'. Otherwise '*found' will be NULL. 115 * 116 * Returns: 117 * idn_success -- check has been done properly. (But this 118 * does not mean that no prohibited character 119 * was found. Check '*found' to see the 120 * result.) 121 */ 122IDN_EXPORT idn_result_t 123idn_nameprep_isprohibited(idn_nameprep_t handle, const unsigned long *str, 124 const unsigned long **found); 125 126/* 127 * Check if an UCS4 string 'str' contains any unassigned characters specified 128 * by the draft. If found, the pointer to the first such character is stored 129 * into '*found'. Otherwise '*found' will be NULL. 130 * 131 * Returns: 132 * idn_success -- check has been done properly. (But this 133 * does not mean that no unassinged character 134 * was found. Check '*found' to see the 135 * result.) 136 */ 137IDN_EXPORT idn_result_t 138idn_nameprep_isunassigned(idn_nameprep_t handle, const unsigned long *str, 139 const unsigned long **found); 140 141/* 142 * Check if an UCS4 string 'str' is valid string specified by ``bidi check'' 143 * of the draft. If it is not valid, the pointer to the first invalid 144 * character is stored into '*found'. Otherwise '*found' will be NULL. 145 * 146 * Returns: 147 * idn_success -- check has been done properly. (But this 148 * does not mean that the string was valid. 149 * Check '*found' to see the result.) 150 */ 151IDN_EXPORT idn_result_t 152idn_nameprep_isvalidbidi(idn_nameprep_t handle, const unsigned long *str, 153 const unsigned long **found); 154 155/* 156 * The following functions are for internal use. 157 * They are used for this module to be add to the checker and mapper modules. 158 */ 159IDN_EXPORT idn_result_t 160idn_nameprep_createproc(const char *parameter, void **handlep); 161 162IDN_EXPORT void 163idn_nameprep_destroyproc(void *handle); 164 165IDN_EXPORT idn_result_t 166idn_nameprep_mapproc(void *handle, const unsigned long *from, 167 unsigned long *to, size_t tolen); 168 169IDN_EXPORT idn_result_t 170idn_nameprep_prohibitproc(void *handle, const unsigned long *str, 171 const unsigned long **found); 172 173IDN_EXPORT idn_result_t 174idn_nameprep_unassignedproc(void *handle, const unsigned long *str, 175 const unsigned long **found); 176 177IDN_EXPORT idn_result_t 178idn_nameprep_bidiproc(void *handle, const unsigned long *str, 179 const unsigned long **found); 180 181#ifdef __cplusplus 182} 183#endif 184 185#endif /* IDN_NAMEPREP_H */ 186