2N/A * Copyright 1998-2008 The OpenLDAP Foundation. 2N/A * All rights reserved. 2N/A * Redistribution and use in source and binary forms, with or without 2N/A * modification, are permitted only as authorized by the OpenLDAP 2N/A * A copy of this license is available in file LICENSE in the 2N/A * top-level directory of the distribution or, alternatively, at 2N/A/* Copyright 2001 Computing Research Labs, New Mexico State University 2N/A * Permission is hereby granted, free of charge, to any person obtaining a 2N/A * copy of this software and associated documentation files (the "Software"), 2N/A * to deal in the Software without restriction, including without limitation 2N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 2N/A * and/or sell copies of the Software, and to permit persons to whom the 2N/A * Software is furnished to do so, subject to the following conditions: 2N/A * The above copyright notice and this permission notice shall be included in 2N/A * all copies or substantial portions of the Software. 2N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2N/A * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 2N/A * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 2N/A * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 2N/A * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2N/A/* $Id: ucdata.c,v 1.4 2001/01/02 18:46:20 mleisher Exp $" */ 2N/A/************************************************************************** 2N/A * Miscellaneous types, data, and support functions. 2N/A **************************************************************************/ 2N/A * A simple array of 32-bit masks for lookup. 2N/A 0x00000001UL,
0x00000002UL,
0x00000004UL,
0x00000008UL,
2N/A 0x00000010UL,
0x00000020UL,
0x00000040UL,
0x00000080UL,
2N/A 0x00000100UL,
0x00000200UL,
0x00000400UL,
0x00000800UL,
2N/A 0x00001000UL,
0x00002000UL,
0x00004000UL,
0x00008000UL,
2N/A 0x00010000UL,
0x00020000UL,
0x00040000UL,
0x00080000UL,
2N/A 0x00100000UL,
0x00200000UL,
0x00400000UL,
0x00800000UL,
2N/A 0x01000000UL,
0x02000000UL,
0x04000000UL,
0x08000000UL,
2N/A 0x10000000UL,
0x20000000UL,
0x40000000UL,
0x80000000UL 2N/A ((((
cc) >>
16) &
0xff) <<
8)|((
cc) >>
24))
2N/A/************************************************************************** 2N/A * Support for the character properties. 2N/A **************************************************************************/ 2N/A * Return -1 on error, 0 if okay 2N/A * The character properties have already been loaded. 2N/A * Unload the current character property data in preparation for 2N/A * loading a new copy. Only the first array has to be deallocated 2N/A * because all the memory for the arrays is allocated as a single 2N/A * Allocate all the storage needed for the lookup table. 2N/A * Calculate the offset into the storage for the ranges. The offsets 2N/A * array is on a 4-byte boundary and one larger than the value provided in 2N/A * the header count field. This means the offset to the ranges must be 2N/A * calculated after aligning the count to a 4-byte boundary. 2N/A * Load the offset array. 2N/A * Do an endian swap if necessary. Don't forget there is an extra node on 2N/A * the end with the final index. 2N/A * Load the ranges. The number of elements is in the last array position 2N/A * Do an endian swap if necessary. 2N/A * Only need to free the offsets because the memory is allocated as a 2N/A * There is an extra node on the end of the offsets to allow this routine 2N/A * to work right. If the index is 0xffff, then there are no nodes for the 2N/A * Locate the next offset that is not 0xffff. The sentinel at the end of 2N/A * the array is the max index value. 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a range pair. 2N/A/************************************************************************** 2N/A * Support for case mapping. 2N/A **************************************************************************/ 2N/A/* These record the number of slots in the map. 2N/A * There are 3 words per slot. 2N/A * Return -1 on error, 0 if okay 2N/A * The case mappings have already been loaded. 2N/A * Set the node count and lengths of the upper and lower case mapping 2N/A * Load the case mapping table. 2N/A * Do an endian swap if necessary. 2N/A * Do the binary search. 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a case mapping triple. 2N/A * The character is lower case. 2N/A * The character is title case. 2N/A * The character is upper case. 2N/A * The character is title case. 2N/A * The offset will always be the same for converting to title case. 2N/A * The character is upper case. 2N/A * The character is lower case. 2N/A/************************************************************************** 2N/A * Support for compositions. 2N/A **************************************************************************/ 2N/A * Return -1 on error, 0 if okay 2N/A * The compositions have already been loaded. 2N/A * Read the composition data in. 2N/A * Do an endian swap if necessary. 2N/A * Assume that the data is ordered on count, so that all compositions 2N/A * of length 2 come first. Only handling length 2 for now. 2N/A /* check if two current characters are L and V */ 2N/A /* make syllable of form LV */ 2N/A /* check if two current characters are LV and T */ 2N/A /* make syllable of form LVT */ 2N/A /* if neither case was true, just add the character */ 2N/A/************************************************************************** 2N/A * Support for decompositions. 2N/A **************************************************************************/ 2N/A * Return -1 on error, 0 if okay 2N/A * The decompositions have already been loaded. 2N/A * Read the decomposition data in. 2N/A * Do an endian swap if necessary. 2N/A * Return -1 on error, 0 if okay 2N/A * The decompositions have already been loaded. 2N/A * Read the decomposition data in. 2N/A * Do an endian swap if necessary. 2N/A * Only need to free the offsets because the memory is allocated as a 2N/A * Only need to free the offsets because the memory is allocated as a 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a code+offset pair. 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a code+offset pair. 2N/A/* mode == 0 for canonical, mode == 1 for compatibility */ 2N/A for (j = 0; j < (
unsigned)
inlen; j++) {
2N/A for (l = i; l > 0; l--)
2N/A for (l = i; l > 0; l--)
2N/A/************************************************************************** 2N/A * Support for combining classes. 2N/A **************************************************************************/ 2N/A * Return -1 on error, 0 if okay 2N/A * The combining classes have already been loaded. 2N/A * Read the combining classes in. 2N/A * Do an endian swap if necessary. 2N/A/************************************************************************** 2N/A * Support for numeric values. 2N/A **************************************************************************/ 2N/A * Return -1 on error, 0 if okay 2N/A * The numbers have already been loaded. 2N/A * Read the combining classes in. 2N/A * Do an endian swap if necessary. 2N/A * Determine the number of values that have to be adjusted. 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a code+offset pair. 2N/A * Determine a "mid" point and adjust to make sure the mid point is at 2N/A * the beginning of a code+offset pair. 2N/A * Initialize with some arbitrary value, because the caller simply cannot 2N/A * tell for sure if the code is a number without calling the ucisnumber() 2N/A * macro before calling this function. 2N/A * Initialize with some arbitrary value, because the caller simply cannot 2N/A * tell for sure if the code is a number without calling the ucisdigit() 2N/A * macro before calling this function. 2N/A/************************************************************************** 2N/A * Setup and cleanup routines. 2N/A **************************************************************************/ 2N/A * Return 0 if okay, negative on error 2N/A * Return 0 if okay, negative on error 2N/A/* ucdata_setup("."); */ 2N/A/* ucdata_cleanup(); */