runetype.h revision 15483
1184610Salfred/*- 2184610Salfred * Copyright (c) 1993 3184610Salfred * The Regents of the University of California. All rights reserved. 4184610Salfred * 5184610Salfred * This code is derived from software contributed to Berkeley by 6184610Salfred * Paul Borman at Krystal Technologies. 7184610Salfred * 8184610Salfred * Redistribution and use in source and binary forms, with or without 9184610Salfred * modification, are permitted provided that the following conditions 10184610Salfred * are met: 11184610Salfred * 1. Redistributions of source code must retain the above copyright 12184610Salfred * notice, this list of conditions and the following disclaimer. 13184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 14184610Salfred * notice, this list of conditions and the following disclaimer in the 15184610Salfred * documentation and/or other materials provided with the distribution. 16184610Salfred * 3. All advertising materials mentioning features or use of this software 17184610Salfred * must display the following acknowledgement: 18184610Salfred * This product includes software developed by the University of 19184610Salfred * California, Berkeley and its contributors. 20184610Salfred * 4. Neither the name of the University nor the names of its contributors 21184610Salfred * may be used to endorse or promote products derived from this software 22184610Salfred * without specific prior written permission. 23184610Salfred * 24184610Salfred * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29194230Sthompsa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30194230Sthompsa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32246122Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33188942Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34246122Shselasky * SUCH DAMAGE. 35187994Salfred * 36184610Salfred * @(#)runetype.h 8.1 (Berkeley) 6/2/93 37184610Salfred */ 38184610Salfred 39184610Salfred#ifndef _RUNETYPE_H_ 40184610Salfred#define _RUNETYPE_H_ 41184610Salfred 42184610Salfred#include <sys/cdefs.h> 43184610Salfred#include <machine/ansi.h> 44184610Salfred 45184610Salfred#ifdef _BSD_RUNE_T_ 46184610Salfredtypedef _BSD_RUNE_T_ rune_t; 47184610Salfred#undef _BSD_RUNE_T_ 48192984Sthompsa#endif 49184610Salfred 50184610Salfred#ifdef _BSD_SIZE_T_ 51184610Salfredtypedef _BSD_SIZE_T_ size_t; 52184610Salfred#undef _BSD_SIZE_T_ 53184610Salfred#endif 54184610Salfred 55184610Salfred#ifdef _BSD_WCHAR_T_ 56184610Salfredtypedef _BSD_WCHAR_T_ wchar_t; 57184610Salfred#undef _BSD_WCHAR_T_ 58184610Salfred#endif 59184610Salfred 60184610Salfred#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ 61184610Salfred#define _CRMASK (~(_CACHED_RUNES - 1)) 62184610Salfred 63184610Salfred/* 64184610Salfred * The lower 8 bits of runetype[] contain the digit value of the rune. 65184610Salfred */ 66184610Salfredtypedef struct { 67184610Salfred rune_t min; /* First rune of the range */ 68184610Salfred rune_t max; /* Last rune (inclusive) of the range */ 69184610Salfred rune_t map; /* What first maps to in maps */ 70184610Salfred unsigned long *types; /* Array of types in range */ 71184610Salfred} _RuneEntry; 72184610Salfred 73184610Salfredtypedef struct { 74184610Salfred int nranges; /* Number of ranges stored */ 75184610Salfred _RuneEntry *ranges; /* Pointer to the ranges */ 76184610Salfred} _RuneRange; 77184610Salfred 78184610Salfredtypedef struct { 79184610Salfred char magic[8]; /* Magic saying what version we are */ 80184610Salfred char encoding[32]; /* ASCII name of this encoding */ 81184610Salfred 82184610Salfred rune_t (*sgetrune) 83184610Salfred __P((const char *, size_t, char const **)); 84184610Salfred int (*sputrune) 85184610Salfred __P((rune_t, char *, size_t, char **)); 86184610Salfred rune_t invalid_rune; 87184610Salfred 88184610Salfred unsigned long runetype[_CACHED_RUNES]; 89184610Salfred rune_t maplower[_CACHED_RUNES]; 90184610Salfred rune_t mapupper[_CACHED_RUNES]; 91184610Salfred 92184610Salfred /* 93184610Salfred * The following are to deal with Runes larger than _CACHED_RUNES - 1. 94184610Salfred * Their data is actually contiguous with this structure so as to make 95184610Salfred * it easier to read/write from/to disk. 96184610Salfred */ 97184610Salfred _RuneRange runetype_ext; 98184610Salfred _RuneRange maplower_ext; 99184610Salfred _RuneRange mapupper_ext; 100184610Salfred 101184610Salfred void *variable; /* Data which depends on the encoding */ 102184610Salfred int variable_len; /* how long that data is */ 103184610Salfred} _RuneLocale; 104184610Salfred 105184610Salfred#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ 106184610Salfred 107184610Salfredextern _RuneLocale _DefaultRuneLocale; 108184610Salfredextern _RuneLocale *_CurrentRuneLocale; 109184610Salfred 110184610Salfred#endif /* !_RUNETYPE_H_ */ 111184610Salfred