michael@0: /* michael@0: * Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved. michael@0: * michael@0: * By using this file, you agree to the terms and conditions set forth bellow. michael@0: * michael@0: * LICENSE TERMS AND CONDITIONS michael@0: * michael@0: * The following License Terms and Conditions apply, unless a different michael@0: * license is obtained from Japan Network Information Center ("JPNIC"), michael@0: * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda, michael@0: * Chiyoda-ku, Tokyo 101-0047, Japan. michael@0: michael@0: * 1. Use, Modification and Redistribution (including distribution of any michael@0: * modified or derived work) in source and/or binary forms is permitted michael@0: * under this License Terms and Conditions. michael@0: * michael@0: * 2. Redistribution of source code must retain the copyright notices as they michael@0: * appear in each source code file, this License Terms and Conditions. michael@0: * michael@0: * 3. Redistribution in binary form must reproduce the Copyright Notice, michael@0: * this License Terms and Conditions, in the documentation and/or other michael@0: * materials provided with the distribution. For the purposes of binary michael@0: * distribution the "Copyright Notice" refers to the following language: michael@0: * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved." michael@0: * michael@0: * 4. The name of JPNIC may not be used to endorse or promote products michael@0: * derived from this Software without specific prior written approval of michael@0: * JPNIC. michael@0: * michael@0: * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A michael@0: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE michael@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR michael@0: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF michael@0: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR michael@0: * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, michael@0: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR michael@0: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF michael@0: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. michael@0: */ michael@0: michael@0: #ifndef nsIDNKitWrapper_h__ michael@0: #define nsIDNKitWrapper_h__ michael@0: michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif /* __cplusplus */ michael@0: michael@0: /* michael@0: * libidnkit result code. michael@0: */ michael@0: typedef enum { michael@0: idn_success, michael@0: idn_notfound, michael@0: idn_invalid_encoding, michael@0: idn_invalid_syntax, michael@0: idn_invalid_name, michael@0: idn_invalid_message, michael@0: idn_invalid_action, michael@0: idn_invalid_codepoint, michael@0: idn_invalid_length, michael@0: idn_buffer_overflow, michael@0: idn_noentry, michael@0: idn_nomemory, michael@0: idn_nofile, michael@0: idn_nomapping, michael@0: idn_context_required, michael@0: idn_prohibited, michael@0: idn_failure /* !!This must be the last one!! */ michael@0: } idn_result_t; michael@0: michael@0: /* michael@0: * BIDI type codes. michael@0: */ michael@0: typedef enum { michael@0: idn_biditype_r_al, michael@0: idn_biditype_l, michael@0: idn_biditype_others michael@0: } idn_biditype_t; michael@0: michael@0: /* michael@0: * A Handle for nameprep operations. michael@0: */ michael@0: typedef struct idn_nameprep *idn_nameprep_t; michael@0: michael@0: michael@0: /* michael@0: * The latest version of nameprep. michael@0: */ michael@0: #define IDN_NAMEPREP_CURRENT "nameprep-11" michael@0: michael@0: #undef assert michael@0: #define assert(a) michael@0: #define TRACE(a) michael@0: michael@0: michael@0: /* race.c */ michael@0: idn_result_t race_decode_decompress(const char *from, michael@0: uint16_t *buf, michael@0: size_t buflen); michael@0: idn_result_t race_compress_encode(const uint16_t *p, michael@0: int compress_mode, michael@0: char *to, size_t tolen); michael@0: int get_compress_mode(uint16_t *p); michael@0: michael@0: michael@0: /* nameprep.c */ michael@0: michael@0: /* michael@0: * Create a handle for nameprep operations. michael@0: * The handle is stored in '*handlep', which is used other functions michael@0: * in this module. michael@0: * The version of the NAMEPREP specification can be specified with michael@0: * 'version' parameter. If 'version' is nullptr, the latest version michael@0: * is used. michael@0: * michael@0: * Returns: michael@0: * idn_success -- ok. michael@0: * idn_notfound -- specified version not found. michael@0: */ michael@0: idn_result_t michael@0: idn_nameprep_create(const char *version, idn_nameprep_t *handlep); michael@0: michael@0: /* michael@0: * Close a handle, which was created by 'idn_nameprep_create'. michael@0: */ michael@0: void michael@0: idn_nameprep_destroy(idn_nameprep_t handle); michael@0: michael@0: /* michael@0: * Perform character mapping on an UCS4 string specified by 'from', and michael@0: * store the result into 'to', whose length is specified by 'tolen'. michael@0: * michael@0: * Returns: michael@0: * idn_success -- ok. michael@0: * idn_buffer_overflow -- result buffer is too small. michael@0: */ michael@0: idn_result_t michael@0: idn_nameprep_map(idn_nameprep_t handle, const uint32_t *from, michael@0: uint32_t *to, size_t tolen); michael@0: michael@0: /* michael@0: * Check if an UCS4 string 'str' contains any prohibited characters specified michael@0: * by the draft. If found, the pointer to the first such character is stored michael@0: * into '*found'. Otherwise '*found' will be nullptr. michael@0: * michael@0: * Returns: michael@0: * idn_success -- check has been done properly. (But this michael@0: * does not mean that no prohibited character michael@0: * was found. Check '*found' to see the michael@0: * result.) michael@0: */ michael@0: idn_result_t michael@0: idn_nameprep_isprohibited(idn_nameprep_t handle, const uint32_t *str, michael@0: const uint32_t **found); michael@0: michael@0: /* michael@0: * Check if an UCS4 string 'str' contains any unassigned characters specified michael@0: * by the draft. If found, the pointer to the first such character is stored michael@0: * into '*found'. Otherwise '*found' will be nullptr. michael@0: * michael@0: * Returns: michael@0: * idn_success -- check has been done properly. (But this michael@0: * does not mean that no unassinged character michael@0: * was found. Check '*found' to see the michael@0: * result.) michael@0: */ michael@0: idn_result_t michael@0: idn_nameprep_isunassigned(idn_nameprep_t handle, const uint32_t *str, michael@0: const uint32_t **found); michael@0: michael@0: /* michael@0: * Check if an UCS4 string 'str' is valid string specified by ``bidi check'' michael@0: * of the draft. If it is not valid, the pointer to the first invalid michael@0: * character is stored into '*found'. Otherwise '*found' will be nullptr. michael@0: * michael@0: * Returns: michael@0: * idn_success -- check has been done properly. (But this michael@0: * does not mean that the string was valid. michael@0: * Check '*found' to see the result.) michael@0: */ michael@0: idn_result_t michael@0: idn_nameprep_isvalidbidi(idn_nameprep_t handle, const uint32_t *str, michael@0: const uint32_t **found); michael@0: michael@0: michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif /* __cplusplus */ michael@0: michael@0: #endif /* nsIDNKitWrapper_h__ */