Line data Source code
1 : /*- 2 : * SPDX-License-Identifier: BSD-3-Clause 3 : * 4 : * Copyright (c) 1993 5 : * The Regents of the University of California. All rights reserved. 6 : * 7 : * This code is derived from software contributed to Berkeley by 8 : * Paul Borman at Krystal Technologies. 9 : * 10 : * Redistribution and use in source and binary forms, with or without 11 : * modification, are permitted provided that the following conditions 12 : * are met: 13 : * 1. Redistributions of source code must retain the above copyright 14 : * notice, this list of conditions and the following disclaimer. 15 : * 2. Redistributions in binary form must reproduce the above copyright 16 : * notice, this list of conditions and the following disclaimer in the 17 : * documentation and/or other materials provided with the distribution. 18 : * 3. Neither the name of the University nor the names of its contributors 19 : * may be used to endorse or promote products derived from this software 20 : * without specific prior written permission. 21 : * 22 : * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 : * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 : * SUCH DAMAGE. 33 : * 34 : * @(#)runetype.h 8.1 (Berkeley) 6/2/93 35 : */ 36 : 37 : #ifndef _RUNETYPE_H_ 38 : #define _RUNETYPE_H_ 39 : 40 : #include <sys/cdefs.h> 41 : #include <sys/_types.h> 42 : 43 : #define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ 44 : #define _CRMASK (~(_CACHED_RUNES - 1)) 45 : 46 : /* 47 : * The lower 8 bits of runetype[] contain the digit value of the rune. 48 : */ 49 : typedef struct { 50 : __rune_t __min; /* First rune of the range */ 51 : __rune_t __max; /* Last rune (inclusive) of the range */ 52 : __rune_t __map; /* What first maps to in maps */ 53 : unsigned long *__types; /* Array of types in range */ 54 : } _RuneEntry; 55 : 56 : typedef struct { 57 : int __nranges; /* Number of ranges stored */ 58 : _RuneEntry *__ranges; /* Pointer to the ranges */ 59 : } _RuneRange; 60 : 61 : typedef struct { 62 : char __magic[8]; /* Magic saying what version we are */ 63 : char __encoding[32]; /* ASCII name of this encoding */ 64 : 65 : __rune_t (*__sgetrune)(const char *, __size_t, char const **); 66 : int (*__sputrune)(__rune_t, char *, __size_t, char **); 67 : __rune_t __invalid_rune; 68 : 69 : unsigned long __runetype[_CACHED_RUNES]; 70 : __rune_t __maplower[_CACHED_RUNES]; 71 : __rune_t __mapupper[_CACHED_RUNES]; 72 : 73 : /* 74 : * The following are to deal with Runes larger than _CACHED_RUNES - 1. 75 : * Their data is actually contiguous with this structure so as to make 76 : * it easier to read/write from/to disk. 77 : */ 78 : _RuneRange __runetype_ext; 79 : _RuneRange __maplower_ext; 80 : _RuneRange __mapupper_ext; 81 : 82 : void *__variable; /* Data which depends on the encoding */ 83 : int __variable_len; /* how long that data is */ 84 : } _RuneLocale; 85 : 86 : #define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ 87 : __BEGIN_DECLS 88 : extern const _RuneLocale _DefaultRuneLocale; 89 : extern const _RuneLocale *_CurrentRuneLocale; 90 : #ifdef __RUNETYPE_INTERNAL 91 : extern const _RuneLocale *__getCurrentRuneLocale(void); 92 : #else 93 : extern _Thread_local const _RuneLocale *_ThreadRuneLocale; 94 21 : static __inline const _RuneLocale *__getCurrentRuneLocale(void) 95 : { 96 : 97 21 : if (_ThreadRuneLocale) 98 0 : return _ThreadRuneLocale; 99 21 : return _CurrentRuneLocale; 100 21 : } 101 : #endif /*__RUNETYPE_INTERNAL */ 102 : #define _CurrentRuneLocale (__getCurrentRuneLocale()) 103 : __END_DECLS 104 : 105 : #endif /* !_RUNETYPE_H_ */