#ifndef lint
#endif
/*
* Copyright (c) 2001 Japan Network Information Center. All rights reserved.
*
* By using this file, you agree to the terms and conditions set forth bellow.
*
* LICENSE TERMS AND CONDITIONS
*
* The following License Terms and Conditions apply, unless a different
* license is obtained from Japan Network Information Center ("JPNIC"),
* a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
* Chiyoda-ku, Tokyo 101-0047, Japan.
*
* 1. Use, Modification and Redistribution (including distribution of any
* under this License Terms and Conditions.
*
* 2. Redistribution of source code must retain the copyright notices as they
* appear in each source code file, this License Terms and Conditions.
*
* 3. Redistribution in binary form must reproduce the Copyright Notice,
* materials provided with the distribution. For the purposes of binary
* distribution the "Copyright Notice" refers to the following language:
* "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
*
* 4. The name of JPNIC may not be used to endorse or promote products
* derived from this Software without specific prior written approval of
* JPNIC.
*
* 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <idn/logmacro.h>
/*
* This module implements UCS 1-to-N mapping.
* To speed up mapping table lookup, a combination of hash and
* binary search is used.
*/
/*
* Mapping entry.
* Entries are sorted by its hash index and code point.
*/
typedef struct {
/*
* Hash table entry.
* Since the entries pointed by ucsmap_hash_t.entry are sorted,
* binary search can be used.
*/
typedef struct {
int n; /* length of 'entry' */
/*
* UCS character buffer for storing target character sequence.
*/
typedef struct ucsmap_buf {
} ucsmap_buf_t;
/*
* Mapping object.
*/
typedef struct idn_ucsmap {
} ucsmap_t;
static int ucsmap_hash(unsigned long v);
unsigned long *map,
TRACE(("idn_ucsmap_create()\n"));
WARNING(("idn_ucsmap_create: malloc failed\n"));
return (idn_nomemory);
}
ctx->entry_size = 0;
ctx->mapdata_size = 0;
ctx->mapdata_used = 0;
return (idn_success);
}
void
TRACE(("idn_ucsmap_destroy()\n"));
}
}
void
}
{
ucsmap_entry_t *e;
/* Make sure it is not fixed yet. */
WARNING(("idn_ucsmap_add: attempt to add to fixed map\n"));
return (idn_failure);
}
if (maplen > MAX_MAPLEN) {
WARNING(("idn_ucsmap_add: maplen too large (> %d)\n",
MAX_MAPLEN));
return (idn_failure);
}
/* Append an entry. */
if (ctx->entry_size == 0)
else
return (idn_nomemory);
}
if (maplen > 0) {
/* Save mapped sequence in the buffer. */
return (idn_nomemory);
} else {
/*
* Zero 'maplen' is perfectly valid meaning one-to-zero
* mapping.
*/
}
return (idn_success);
}
void
ucsmap_entry_t *e;
int last_hidx;
int i;
TRACE(("idn_ucsmap_fix()\n"));
return;
/* Initialize hash. */
for (i = 0; i < UCSMAP_HASH_SIZE; i++) {
}
return;
/* Sort entries by the hash value and code point. */
/*
* Now the entries are sorted by their hash value, and
* sorted by its code point among the ones with the same hash value.
*/
/* Build hash table. */
last_hidx = -1;
}
}
}
int hash;
ucsmap_entry_t *e;
int n;
TRACE(("idn_ucsmap_map(v=U+%lX)\n", v));
WARNING(("idn_ucsmap_map: not fixed yet\n"));
return (idn_failure);
}
/* First, look up hash table. */
hash = ucsmap_hash(v);
goto nomap;
/* Then do binary search. */
lo = 0;
hi = n - 1;
else {
/* Found. */
return (idn_buffer_overflow);
return (idn_success);
}
}
/*
* Not found. Put the original character to 'to'
* just for convenience.
*/
if (tolen < 1)
return (idn_buffer_overflow);
*to = v;
*maplenp = 1;
return (idn_nomapping);
}
static int
ucsmap_hash(unsigned long v) {
return (v % UCSMAP_HASH_SIZE);
}
static unsigned long *
unsigned long *p;
/*
* If the current buffer (the first one in the ctx->mapdata list)
* has enough space, use it. Otherwise, allocate a new buffer and
* insert it at the beginning of the list.
*/
if (maplen > DEFAULT_BUF_SIZE)
else
sizeof(unsigned long) * allocsize);
return (NULL);
ctx->mapdata_used = 0;
}
return (p);
}
static void
}
}
static int
return (-1);
return (1);
return (-1);
return (1);
else
return (0);
}