runetype.h revision 15483
11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * This code is derived from software contributed to Berkeley by 61539Srgrimes * Paul Borman at Krystal Technologies. 71539Srgrimes * 81539Srgrimes * Redistribution and use in source and binary forms, with or without 91539Srgrimes * modification, are permitted provided that the following conditions 101539Srgrimes * are met: 111539Srgrimes * 1. Redistributions of source code must retain the above copyright 121539Srgrimes * notice, this list of conditions and the following disclaimer. 131539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141539Srgrimes * notice, this list of conditions and the following disclaimer in the 151539Srgrimes * documentation and/or other materials provided with the distribution. 161539Srgrimes * 3. All advertising materials mentioning features or use of this software 171539Srgrimes * must display the following acknowledgement: 181539Srgrimes * This product includes software developed by the University of 191539Srgrimes * California, Berkeley and its contributors. 201539Srgrimes * 4. Neither the name of the University nor the names of its contributors 211539Srgrimes * may be used to endorse or promote products derived from this software 221539Srgrimes * without specific prior written permission. 231539Srgrimes * 241539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341539Srgrimes * SUCH DAMAGE. 351539Srgrimes * 361539Srgrimes * @(#)runetype.h 8.1 (Berkeley) 6/2/93 371539Srgrimes */ 381539Srgrimes 391539Srgrimes#ifndef _RUNETYPE_H_ 401539Srgrimes#define _RUNETYPE_H_ 411539Srgrimes 4215483Sbde#include <sys/cdefs.h> 431539Srgrimes#include <machine/ansi.h> 441539Srgrimes 4515483Sbde#ifdef _BSD_RUNE_T_ 4615483Sbdetypedef _BSD_RUNE_T_ rune_t; 4715483Sbde#undef _BSD_RUNE_T_ 481539Srgrimes#endif 491539Srgrimes 5015287Sache#ifdef _BSD_SIZE_T_ 5115287Sachetypedef _BSD_SIZE_T_ size_t; 5215287Sache#undef _BSD_SIZE_T_ 5315287Sache#endif 5415287Sache 5515483Sbde#ifdef _BSD_WCHAR_T_ 5615483Sbdetypedef _BSD_WCHAR_T_ wchar_t; 5715483Sbde#undef _BSD_WCHAR_T_ 5815483Sbde#endif 5915483Sbde 601539Srgrimes#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ 611539Srgrimes#define _CRMASK (~(_CACHED_RUNES - 1)) 621539Srgrimes 631539Srgrimes/* 641539Srgrimes * The lower 8 bits of runetype[] contain the digit value of the rune. 651539Srgrimes */ 661539Srgrimestypedef struct { 671539Srgrimes rune_t min; /* First rune of the range */ 681539Srgrimes rune_t max; /* Last rune (inclusive) of the range */ 691539Srgrimes rune_t map; /* What first maps to in maps */ 701539Srgrimes unsigned long *types; /* Array of types in range */ 711539Srgrimes} _RuneEntry; 721539Srgrimes 731539Srgrimestypedef struct { 741539Srgrimes int nranges; /* Number of ranges stored */ 751539Srgrimes _RuneEntry *ranges; /* Pointer to the ranges */ 761539Srgrimes} _RuneRange; 771539Srgrimes 781539Srgrimestypedef struct { 791539Srgrimes char magic[8]; /* Magic saying what version we are */ 801539Srgrimes char encoding[32]; /* ASCII name of this encoding */ 811539Srgrimes 821539Srgrimes rune_t (*sgetrune) 8315287Sache __P((const char *, size_t, char const **)); 841539Srgrimes int (*sputrune) 8515287Sache __P((rune_t, char *, size_t, char **)); 861539Srgrimes rune_t invalid_rune; 871539Srgrimes 881539Srgrimes unsigned long runetype[_CACHED_RUNES]; 891539Srgrimes rune_t maplower[_CACHED_RUNES]; 901539Srgrimes rune_t mapupper[_CACHED_RUNES]; 911539Srgrimes 921539Srgrimes /* 931539Srgrimes * The following are to deal with Runes larger than _CACHED_RUNES - 1. 941539Srgrimes * Their data is actually contiguous with this structure so as to make 951539Srgrimes * it easier to read/write from/to disk. 961539Srgrimes */ 971539Srgrimes _RuneRange runetype_ext; 981539Srgrimes _RuneRange maplower_ext; 991539Srgrimes _RuneRange mapupper_ext; 1001539Srgrimes 1011539Srgrimes void *variable; /* Data which depends on the encoding */ 1021539Srgrimes int variable_len; /* how long that data is */ 1031539Srgrimes} _RuneLocale; 1041539Srgrimes 1051539Srgrimes#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ 1061539Srgrimes 1071539Srgrimesextern _RuneLocale _DefaultRuneLocale; 1081539Srgrimesextern _RuneLocale *_CurrentRuneLocale; 1091539Srgrimes 1101539Srgrimes#endif /* !_RUNETYPE_H_ */ 111