Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * By using this file, you agree to the terms and conditions set forth bellow. |
michael@0 | 5 | * |
michael@0 | 6 | * LICENSE TERMS AND CONDITIONS |
michael@0 | 7 | * |
michael@0 | 8 | * The following License Terms and Conditions apply, unless a different |
michael@0 | 9 | * license is obtained from Japan Network Information Center ("JPNIC"), |
michael@0 | 10 | * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda, |
michael@0 | 11 | * Chiyoda-ku, Tokyo 101-0047, Japan. |
michael@0 | 12 | |
michael@0 | 13 | * 1. Use, Modification and Redistribution (including distribution of any |
michael@0 | 14 | * modified or derived work) in source and/or binary forms is permitted |
michael@0 | 15 | * under this License Terms and Conditions. |
michael@0 | 16 | * |
michael@0 | 17 | * 2. Redistribution of source code must retain the copyright notices as they |
michael@0 | 18 | * appear in each source code file, this License Terms and Conditions. |
michael@0 | 19 | * |
michael@0 | 20 | * 3. Redistribution in binary form must reproduce the Copyright Notice, |
michael@0 | 21 | * this License Terms and Conditions, in the documentation and/or other |
michael@0 | 22 | * materials provided with the distribution. For the purposes of binary |
michael@0 | 23 | * distribution the "Copyright Notice" refers to the following language: |
michael@0 | 24 | * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved." |
michael@0 | 25 | * |
michael@0 | 26 | * 4. The name of JPNIC may not be used to endorse or promote products |
michael@0 | 27 | * derived from this Software without specific prior written approval of |
michael@0 | 28 | * JPNIC. |
michael@0 | 29 | * |
michael@0 | 30 | * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC |
michael@0 | 31 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 32 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
michael@0 | 33 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE |
michael@0 | 34 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
michael@0 | 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
michael@0 | 36 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
michael@0 | 37 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
michael@0 | 38 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
michael@0 | 39 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
michael@0 | 40 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | #ifndef nsIDNKitWrapper_h__ |
michael@0 | 44 | #define nsIDNKitWrapper_h__ |
michael@0 | 45 | |
michael@0 | 46 | #include <stdint.h> |
michael@0 | 47 | |
michael@0 | 48 | #ifdef __cplusplus |
michael@0 | 49 | extern "C" { |
michael@0 | 50 | #endif /* __cplusplus */ |
michael@0 | 51 | |
michael@0 | 52 | /* |
michael@0 | 53 | * libidnkit result code. |
michael@0 | 54 | */ |
michael@0 | 55 | typedef enum { |
michael@0 | 56 | idn_success, |
michael@0 | 57 | idn_notfound, |
michael@0 | 58 | idn_invalid_encoding, |
michael@0 | 59 | idn_invalid_syntax, |
michael@0 | 60 | idn_invalid_name, |
michael@0 | 61 | idn_invalid_message, |
michael@0 | 62 | idn_invalid_action, |
michael@0 | 63 | idn_invalid_codepoint, |
michael@0 | 64 | idn_invalid_length, |
michael@0 | 65 | idn_buffer_overflow, |
michael@0 | 66 | idn_noentry, |
michael@0 | 67 | idn_nomemory, |
michael@0 | 68 | idn_nofile, |
michael@0 | 69 | idn_nomapping, |
michael@0 | 70 | idn_context_required, |
michael@0 | 71 | idn_prohibited, |
michael@0 | 72 | idn_failure /* !!This must be the last one!! */ |
michael@0 | 73 | } idn_result_t; |
michael@0 | 74 | |
michael@0 | 75 | /* |
michael@0 | 76 | * BIDI type codes. |
michael@0 | 77 | */ |
michael@0 | 78 | typedef enum { |
michael@0 | 79 | idn_biditype_r_al, |
michael@0 | 80 | idn_biditype_l, |
michael@0 | 81 | idn_biditype_others |
michael@0 | 82 | } idn_biditype_t; |
michael@0 | 83 | |
michael@0 | 84 | /* |
michael@0 | 85 | * A Handle for nameprep operations. |
michael@0 | 86 | */ |
michael@0 | 87 | typedef struct idn_nameprep *idn_nameprep_t; |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | /* |
michael@0 | 91 | * The latest version of nameprep. |
michael@0 | 92 | */ |
michael@0 | 93 | #define IDN_NAMEPREP_CURRENT "nameprep-11" |
michael@0 | 94 | |
michael@0 | 95 | #undef assert |
michael@0 | 96 | #define assert(a) |
michael@0 | 97 | #define TRACE(a) |
michael@0 | 98 | |
michael@0 | 99 | |
michael@0 | 100 | /* race.c */ |
michael@0 | 101 | idn_result_t race_decode_decompress(const char *from, |
michael@0 | 102 | uint16_t *buf, |
michael@0 | 103 | size_t buflen); |
michael@0 | 104 | idn_result_t race_compress_encode(const uint16_t *p, |
michael@0 | 105 | int compress_mode, |
michael@0 | 106 | char *to, size_t tolen); |
michael@0 | 107 | int get_compress_mode(uint16_t *p); |
michael@0 | 108 | |
michael@0 | 109 | |
michael@0 | 110 | /* nameprep.c */ |
michael@0 | 111 | |
michael@0 | 112 | /* |
michael@0 | 113 | * Create a handle for nameprep operations. |
michael@0 | 114 | * The handle is stored in '*handlep', which is used other functions |
michael@0 | 115 | * in this module. |
michael@0 | 116 | * The version of the NAMEPREP specification can be specified with |
michael@0 | 117 | * 'version' parameter. If 'version' is nullptr, the latest version |
michael@0 | 118 | * is used. |
michael@0 | 119 | * |
michael@0 | 120 | * Returns: |
michael@0 | 121 | * idn_success -- ok. |
michael@0 | 122 | * idn_notfound -- specified version not found. |
michael@0 | 123 | */ |
michael@0 | 124 | idn_result_t |
michael@0 | 125 | idn_nameprep_create(const char *version, idn_nameprep_t *handlep); |
michael@0 | 126 | |
michael@0 | 127 | /* |
michael@0 | 128 | * Close a handle, which was created by 'idn_nameprep_create'. |
michael@0 | 129 | */ |
michael@0 | 130 | void |
michael@0 | 131 | idn_nameprep_destroy(idn_nameprep_t handle); |
michael@0 | 132 | |
michael@0 | 133 | /* |
michael@0 | 134 | * Perform character mapping on an UCS4 string specified by 'from', and |
michael@0 | 135 | * store the result into 'to', whose length is specified by 'tolen'. |
michael@0 | 136 | * |
michael@0 | 137 | * Returns: |
michael@0 | 138 | * idn_success -- ok. |
michael@0 | 139 | * idn_buffer_overflow -- result buffer is too small. |
michael@0 | 140 | */ |
michael@0 | 141 | idn_result_t |
michael@0 | 142 | idn_nameprep_map(idn_nameprep_t handle, const uint32_t *from, |
michael@0 | 143 | uint32_t *to, size_t tolen); |
michael@0 | 144 | |
michael@0 | 145 | /* |
michael@0 | 146 | * Check if an UCS4 string 'str' contains any prohibited characters specified |
michael@0 | 147 | * by the draft. If found, the pointer to the first such character is stored |
michael@0 | 148 | * into '*found'. Otherwise '*found' will be nullptr. |
michael@0 | 149 | * |
michael@0 | 150 | * Returns: |
michael@0 | 151 | * idn_success -- check has been done properly. (But this |
michael@0 | 152 | * does not mean that no prohibited character |
michael@0 | 153 | * was found. Check '*found' to see the |
michael@0 | 154 | * result.) |
michael@0 | 155 | */ |
michael@0 | 156 | idn_result_t |
michael@0 | 157 | idn_nameprep_isprohibited(idn_nameprep_t handle, const uint32_t *str, |
michael@0 | 158 | const uint32_t **found); |
michael@0 | 159 | |
michael@0 | 160 | /* |
michael@0 | 161 | * Check if an UCS4 string 'str' contains any unassigned characters specified |
michael@0 | 162 | * by the draft. If found, the pointer to the first such character is stored |
michael@0 | 163 | * into '*found'. Otherwise '*found' will be nullptr. |
michael@0 | 164 | * |
michael@0 | 165 | * Returns: |
michael@0 | 166 | * idn_success -- check has been done properly. (But this |
michael@0 | 167 | * does not mean that no unassinged character |
michael@0 | 168 | * was found. Check '*found' to see the |
michael@0 | 169 | * result.) |
michael@0 | 170 | */ |
michael@0 | 171 | idn_result_t |
michael@0 | 172 | idn_nameprep_isunassigned(idn_nameprep_t handle, const uint32_t *str, |
michael@0 | 173 | const uint32_t **found); |
michael@0 | 174 | |
michael@0 | 175 | /* |
michael@0 | 176 | * Check if an UCS4 string 'str' is valid string specified by ``bidi check'' |
michael@0 | 177 | * of the draft. If it is not valid, the pointer to the first invalid |
michael@0 | 178 | * character is stored into '*found'. Otherwise '*found' will be nullptr. |
michael@0 | 179 | * |
michael@0 | 180 | * Returns: |
michael@0 | 181 | * idn_success -- check has been done properly. (But this |
michael@0 | 182 | * does not mean that the string was valid. |
michael@0 | 183 | * Check '*found' to see the result.) |
michael@0 | 184 | */ |
michael@0 | 185 | idn_result_t |
michael@0 | 186 | idn_nameprep_isvalidbidi(idn_nameprep_t handle, const uint32_t *str, |
michael@0 | 187 | const uint32_t **found); |
michael@0 | 188 | |
michael@0 | 189 | |
michael@0 | 190 | |
michael@0 | 191 | #ifdef __cplusplus |
michael@0 | 192 | } |
michael@0 | 193 | #endif /* __cplusplus */ |
michael@0 | 194 | |
michael@0 | 195 | #endif /* nsIDNKitWrapper_h__ */ |