Back to index

lightning-sunbird  0.9+nobinonly
nsIDNKitInterface.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved.
00003  * 
00004  * By using this file, you agree to the terms and conditions set forth bellow.
00005  * 
00006  *                   LICENSE TERMS AND CONDITIONS 
00007  * 
00008  * The following License Terms and Conditions apply, unless a different
00009  * license is obtained from Japan Network Information Center ("JPNIC"),
00010  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
00011  * Chiyoda-ku, Tokyo 101-0047, Japan.
00012 
00013  * 1. Use, Modification and Redistribution (including distribution of any
00014  *    modified or derived work) in source and/or binary forms is permitted
00015  *    under this License Terms and Conditions.
00016  * 
00017  * 2. Redistribution of source code must retain the copyright notices as they
00018  *    appear in each source code file, this License Terms and Conditions.
00019  * 
00020  * 3. Redistribution in binary form must reproduce the Copyright Notice,
00021  *    this License Terms and Conditions, in the documentation and/or other
00022  *    materials provided with the distribution.  For the purposes of binary
00023  *    distribution the "Copyright Notice" refers to the following language:
00024  *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
00025  * 
00026  * 4. The name of JPNIC may not be used to endorse or promote products
00027  *    derived from this Software without specific prior written approval of
00028  *    JPNIC.
00029  * 
00030  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
00031  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00032  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00033  *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
00034  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00035  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00036  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
00037  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00038  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00039  *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00040  *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00041  */
00042 
00043 #ifndef nsIDNKitWrapper_h__
00044 #define nsIDNKitWrapper_h__
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif /* __cplusplus */
00049 
00050 #include "prtypes.h"
00051 
00052 /*
00053  * libidnkit result code.
00054  */
00055 typedef enum {
00056        idn_success,
00057        idn_notfound,
00058        idn_invalid_encoding,
00059        idn_invalid_syntax,
00060        idn_invalid_name,
00061        idn_invalid_message,
00062        idn_invalid_action,
00063        idn_invalid_codepoint,
00064        idn_invalid_length,
00065        idn_buffer_overflow,
00066        idn_noentry,
00067        idn_nomemory,
00068        idn_nofile,
00069        idn_nomapping,
00070        idn_context_required,
00071        idn_prohibited,
00072        idn_failure   /* !!This must be the last one!! */
00073 } idn_result_t;
00074 
00075 /*
00076  * BIDI type codes.
00077  */      
00078 typedef enum {
00079        idn_biditype_r_al,
00080        idn_biditype_l,
00081        idn_biditype_others
00082 } idn_biditype_t;
00083 
00084 /*
00085  * A Handle for nameprep operations.
00086  */
00087 typedef struct idn_nameprep *idn_nameprep_t;
00088 
00089 
00090 /*
00091  * The latest version of nameprep.
00092  */
00093 #define IDN_NAMEPREP_CURRENT       "nameprep-11"
00094 
00095 #define assert(a)
00096 #define TRACE(a)
00097 
00098 
00099 /* race.c */
00100 idn_result_t  race_decode_decompress(const char *from,
00101                                           PRUint16 *buf,
00102                                           size_t buflen);
00103 idn_result_t  race_compress_encode(const PRUint16 *p,
00104                                         int compress_mode,
00105                                         char *to, size_t tolen);
00106 int           get_compress_mode(PRUint16 *p);
00107 
00108 
00109 /* nameprep.c */
00110 
00111 /*
00112  * Create a handle for nameprep operations.
00113  * The handle is stored in '*handlep', which is used other functions
00114  * in this module.
00115  * The version of the NAMEPREP specification can be specified with
00116  * 'version' parameter.  If 'version' is NULL, the latest version
00117  * is used.
00118  *
00119  * Returns:
00120  *     idn_success          -- ok.
00121  *     idn_notfound         -- specified version not found.
00122  */
00123 idn_result_t
00124 idn_nameprep_create(const char *version, idn_nameprep_t *handlep);
00125 
00126 /*
00127  * Close a handle, which was created by 'idn_nameprep_create'.
00128  */
00129 void
00130 idn_nameprep_destroy(idn_nameprep_t handle);
00131 
00132 /*
00133  * Perform character mapping on an UCS4 string specified by 'from', and
00134  * store the result into 'to', whose length is specified by 'tolen'.
00135  *
00136  * Returns:
00137  *     idn_success          -- ok.
00138  *     idn_buffer_overflow  -- result buffer is too small.
00139  */
00140 idn_result_t
00141 idn_nameprep_map(idn_nameprep_t handle, const PRUint32 *from,
00142                PRUint32 *to, size_t tolen);
00143 
00144 /*
00145  * Check if an UCS4 string 'str' contains any prohibited characters specified
00146  * by the draft.  If found, the pointer to the first such character is stored
00147  * into '*found'.  Otherwise '*found' will be NULL.
00148  *
00149  * Returns:
00150  *     idn_success          -- check has been done properly. (But this
00151  *                             does not mean that no prohibited character
00152  *                             was found.  Check '*found' to see the
00153  *                             result.)
00154  */
00155 idn_result_t
00156 idn_nameprep_isprohibited(idn_nameprep_t handle, const PRUint32 *str,
00157                        const PRUint32 **found);
00158 
00159 /*
00160  * Check if an UCS4 string 'str' contains any unassigned characters specified
00161  * by the draft.  If found, the pointer to the first such character is stored
00162  * into '*found'.  Otherwise '*found' will be NULL.
00163  *
00164  * Returns:
00165  *     idn_success          -- check has been done properly. (But this
00166  *                             does not mean that no unassinged character
00167  *                             was found.  Check '*found' to see the
00168  *                             result.)
00169  */
00170 idn_result_t
00171 idn_nameprep_isunassigned(idn_nameprep_t handle, const PRUint32 *str,
00172                        const PRUint32 **found);
00173 
00174 /*
00175  * Check if an UCS4 string 'str' is valid string specified by ``bidi check''
00176  * of the draft.  If it is not valid, the pointer to the first invalid
00177  * character is stored into '*found'.  Otherwise '*found' will be NULL.
00178  *
00179  * Returns:
00180  *     idn_success          -- check has been done properly. (But this
00181  *                             does not mean that the string was valid.
00182  *                             Check '*found' to see the result.)
00183  */
00184 idn_result_t
00185 idn_nameprep_isvalidbidi(idn_nameprep_t handle, const PRUint32 *str,
00186                       const PRUint32 **found);
00187 
00188 
00189 
00190 #ifdef __cplusplus
00191 }
00192 #endif /* __cplusplus */
00193 
00194 #endif /* nsIDNKitWrapper_h__ */