runetype.h revision 15287
1290001Sglebius/*- 2290001Sglebius * Copyright (c) 1993 3290001Sglebius * The Regents of the University of California. All rights reserved. 4290001Sglebius * 5290001Sglebius * This code is derived from software contributed to Berkeley by 6290001Sglebius * Paul Borman at Krystal Technologies. 7290001Sglebius * 8290001Sglebius * Redistribution and use in source and binary forms, with or without 9290001Sglebius * modification, are permitted provided that the following conditions 10290001Sglebius * are met: 11290001Sglebius * 1. Redistributions of source code must retain the above copyright 12290001Sglebius * notice, this list of conditions and the following disclaimer. 13290001Sglebius * 2. Redistributions in binary form must reproduce the above copyright 14290001Sglebius * notice, this list of conditions and the following disclaimer in the 15290001Sglebius * documentation and/or other materials provided with the distribution. 16290001Sglebius * 3. All advertising materials mentioning features or use of this software 17290001Sglebius * must display the following acknowledgement: 18290001Sglebius * This product includes software developed by the University of 19290001Sglebius * California, Berkeley and its contributors. 20290001Sglebius * 4. Neither the name of the University nor the names of its contributors 21290001Sglebius * may be used to endorse or promote products derived from this software 22290001Sglebius * without specific prior written permission. 23290001Sglebius * 24290001Sglebius * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25290001Sglebius * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26290001Sglebius * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27290001Sglebius * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28290001Sglebius * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29290001Sglebius * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30290001Sglebius * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31290001Sglebius * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32290001Sglebius * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33290001Sglebius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34290001Sglebius * SUCH DAMAGE. 35290001Sglebius * 36290001Sglebius * @(#)runetype.h 8.1 (Berkeley) 6/2/93 37290001Sglebius */ 38290001Sglebius 39290001Sglebius#ifndef _RUNETYPE_H_ 40290001Sglebius#define _RUNETYPE_H_ 41290001Sglebius 42290001Sglebius#include <machine/ansi.h> 43290001Sglebius#include <sys/cdefs.h> 44290001Sglebius 45290001Sglebius#ifdef _BSD_WCHAR_T_ 46290001Sglebiustypedef _BSD_WCHAR_T_ rune_t; 47290001Sglebiustypedef _BSD_WCHAR_T_ wchar_t; 48290001Sglebius#undef _BSD_WCHAR_T_ 49290001Sglebius#endif 50290001Sglebius 51290001Sglebius#ifdef _BSD_SIZE_T_ 52290001Sglebiustypedef _BSD_SIZE_T_ size_t; 53290001Sglebius#undef _BSD_SIZE_T_ 54290001Sglebius#endif 55290001Sglebius 56290001Sglebius#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ 57290001Sglebius#define _CRMASK (~(_CACHED_RUNES - 1)) 58290001Sglebius 59290001Sglebius/* 60290001Sglebius * The lower 8 bits of runetype[] contain the digit value of the rune. 61290001Sglebius */ 62290001Sglebiustypedef struct { 63290001Sglebius rune_t min; /* First rune of the range */ 64290001Sglebius rune_t max; /* Last rune (inclusive) of the range */ 65290001Sglebius rune_t map; /* What first maps to in maps */ 66290001Sglebius unsigned long *types; /* Array of types in range */ 67290001Sglebius} _RuneEntry; 68290001Sglebius 69290001Sglebiustypedef struct { 70290001Sglebius int nranges; /* Number of ranges stored */ 71290001Sglebius _RuneEntry *ranges; /* Pointer to the ranges */ 72290001Sglebius} _RuneRange; 73290001Sglebius 74290001Sglebiustypedef struct { 75290001Sglebius char magic[8]; /* Magic saying what version we are */ 76290001Sglebius char encoding[32]; /* ASCII name of this encoding */ 77290001Sglebius 78290001Sglebius rune_t (*sgetrune) 79290001Sglebius __P((const char *, size_t, char const **)); 80290001Sglebius int (*sputrune) 81290001Sglebius __P((rune_t, char *, size_t, char **)); 82290001Sglebius rune_t invalid_rune; 83290001Sglebius 84290001Sglebius unsigned long runetype[_CACHED_RUNES]; 85290001Sglebius rune_t maplower[_CACHED_RUNES]; 86290001Sglebius rune_t mapupper[_CACHED_RUNES]; 87290001Sglebius 88290001Sglebius /* 89290001Sglebius * The following are to deal with Runes larger than _CACHED_RUNES - 1. 90290001Sglebius * Their data is actually contiguous with this structure so as to make 91290001Sglebius * it easier to read/write from/to disk. 92290001Sglebius */ 93290001Sglebius _RuneRange runetype_ext; 94290001Sglebius _RuneRange maplower_ext; 95290001Sglebius _RuneRange mapupper_ext; 96290001Sglebius 97290001Sglebius void *variable; /* Data which depends on the encoding */ 98290001Sglebius int variable_len; /* how long that data is */ 99290001Sglebius} _RuneLocale; 100290001Sglebius 101290001Sglebius#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ 102290001Sglebius 103290001Sglebiusextern _RuneLocale _DefaultRuneLocale; 104290001Sglebiusextern _RuneLocale *_CurrentRuneLocale; 105290001Sglebius 106290001Sglebius#endif /* !_RUNETYPE_H_ */ 107290001Sglebius