1 /*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)runetype.h 8.1 (Berkeley) 06/02/93 11 */ 12 13 #ifndef _RUNETYPE_H_ 14 #define _RUNETYPE_H_ 15 16 #include <machine/ansi.h> 17 #include <sys/cdefs.h> 18 19 #ifdef _BSD_WCHAR_T_ 20 typedef _BSD_WCHAR_T_ rune_t; 21 typedef _BSD_WCHAR_T_ wchar_t; 22 #undef _BSD_WCHAR_T_ 23 #endif 24 25 #define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ 26 #define _CRMASK (~(_CACHED_RUNES - 1)) 27 28 /* 29 * The lower 8 bits of runetype[] contain the digit value of the rune. 30 */ 31 typedef struct { 32 rune_t min; /* First rune of the range */ 33 rune_t max; /* Last rune (inclusive) of the range */ 34 rune_t map; /* What first maps to in maps */ 35 unsigned long *types; /* Array of types in range */ 36 } _RuneEntry; 37 38 typedef struct { 39 int nranges; /* Number of ranges stored */ 40 _RuneEntry *ranges; /* Pointer to the ranges */ 41 } _RuneRange; 42 43 typedef struct { 44 char magic[8]; /* Magic saying what version we are */ 45 char encoding[32]; /* ASCII name of this encoding */ 46 47 rune_t (*sgetrune) 48 __P((const char *, unsigned int, char const **)); 49 int (*sputrune) 50 __P((rune_t, char *, unsigned int, char **)); 51 rune_t invalid_rune; 52 53 unsigned long runetype[_CACHED_RUNES]; 54 rune_t maplower[_CACHED_RUNES]; 55 rune_t mapupper[_CACHED_RUNES]; 56 57 /* 58 * The following are to deal with Runes larger than _CACHED_RUNES - 1. 59 * Their data is actually contiguous with this structure so as to make 60 * it easier to read/write from/to disk. 61 */ 62 _RuneRange runetype_ext; 63 _RuneRange maplower_ext; 64 _RuneRange mapupper_ext; 65 66 void *variable; /* Data which depends on the encoding */ 67 int variable_len; /* how long that data is */ 68 } _RuneLocale; 69 70 #define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ 71 72 extern _RuneLocale _DefaultRuneLocale; 73 extern _RuneLocale *_CurrentRuneLocale; 74 75 #endif /* !_RUNETYPE_H_ */ 76