1139825Simp/* $NetBSD: runetype_file.h,v 1.2 2010/06/19 13:26:52 tnozaki Exp $ */ 21541Srgrimes 31541Srgrimes/*- 41541Srgrimes * Copyright (c) 1993 51541Srgrimes * The Regents of the University of California. All rights reserved. 61541Srgrimes * 71541Srgrimes * This code is derived from software contributed to Berkeley by 81541Srgrimes * Paul Borman at Krystal Technologies. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. Neither the name of the University nor the names of its contributors 191541Srgrimes * may be used to endorse or promote products derived from this software 201541Srgrimes * without specific prior written permission. 211541Srgrimes * 221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321817Sdg * SUCH DAMAGE. 331541Srgrimes * 341541Srgrimes * @(#)runetype.h 8.1 (Berkeley) 6/2/93 351541Srgrimes */ 361541Srgrimes 371541Srgrimes#ifndef _RUNETYPE_FILE_H_ 381541Srgrimes#define _RUNETYPE_FILE_H_ 395455Sdg 401541Srgrimes#include <sys/cdefs.h> 411541Srgrimes#include <sys/types.h> 421541Srgrimes 431541Srgrimes#include "ctype_local.h" 441541Srgrimes 455455Sdg/* for cross host tools on older systems */ 465455Sdg#ifndef UINT32_C 475455Sdg/* assumes sizeof(unsigned int)>=4 */ 481541Srgrimes#define UINT32_C(c) ((uint32_t)(c##U)) 495455Sdg#endif 501541Srgrimes 511541Srgrimestypedef uint32_t __nbrune_t; 521541Srgrimestypedef uint64_t __runepad_t; 531541Srgrimes 541541Srgrimes#define _DEFAULT_INVALID_RUNE ((__nbrune_t)-3) 551541Srgrimes 561541Srgrimes/* 571541Srgrimes * The lower 8 bits of runetype[] contain the digit value of the rune. 581541Srgrimes */ 591817Sdgtypedef uint32_t _RuneType; 6050477Speter#define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */ 611541Srgrimes#define _RUNETYPE_C UINT32_C(0x00000200) /* Control */ 621541Srgrimes#define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */ 631541Srgrimes#define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */ 641541Srgrimes#define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */ 651541Srgrimes#define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */ 661541Srgrimes#define _RUNETYPE_S UINT32_C(0x00004000) /* Space */ 671541Srgrimes#define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */ 681541Srgrimes#define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */ 691541Srgrimes#define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */ 701541Srgrimes#define _RUNETYPE_R UINT32_C(0x00040000) /* Print */ 711541Srgrimes#define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */ 721541Srgrimes#define _RUNETYPE_T UINT32_C(0x00100000) /* Special */ 731541Srgrimes#define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */ 741541Srgrimes#define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */ 751541Srgrimes#define _RUNETYPE_SWS 30 /* Bits to shift to get width */ 761541Srgrimes#define _RUNETYPE_SW0 UINT32_C(0x20000000) /* 0 width character */ 775455Sdg#define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */ 785455Sdg#define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */ 791541Srgrimes#define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */ 805455Sdg 811541Srgrimes/* 821541Srgrimes * rune file format. network endian. 831541Srgrimes */ 8455206Spetertypedef struct { 8532995Sbde int32_t fre_min; /* First rune of the range */ 8683366Sjulian int32_t fre_max; /* Last rune (inclusive) of the range */ 8732995Sbde int32_t fre_map; /* What first maps to in maps */ 88110957Salc uint32_t fre_pad1; /* backward compatibility */ 89110957Salc __runepad_t fre_pad2; /* backward compatibility */ 90110957Salc} __packed _FileRuneEntry; 91110957Salc 92110957Salc 93178875Salctypedef struct { 94178875Salc uint32_t frr_nranges; /* Number of ranges stored */ 9592727Salfred uint32_t frr_pad1; /* backward compatibility */ 9692727Salfred __runepad_t frr_pad2; /* backward compatibility */ 9792727Salfred} __packed _FileRuneRange; 9892727Salfred 9994777Speter 100175067Salctypedef struct { 101175067Salc char frl_magic[8]; /* Magic saying what version we are */ 102175041Salc char frl_encoding[32];/* ASCII name of this encoding */ 103159627Sups 104159303Salc __runepad_t frl_pad1; /* backward compatibility */ 105159303Salc __runepad_t frl_pad2; /* backward compatibility */ 106112569Sjake int32_t frl_invalid_rune; 107119999Salc uint32_t frl_pad3; /* backward compatibility */ 108119999Salc 10992727Salfred _RuneType frl_runetype[_CTYPE_CACHE_SIZE]; 110127869Salc int32_t frl_maplower[_CTYPE_CACHE_SIZE]; 11192727Salfred int32_t frl_mapupper[_CTYPE_CACHE_SIZE]; 112120722Salc 11392727Salfred /* 114112569Sjake * The following are to deal with Runes larger than _CTYPE_CACHE_SIZE - 1. 11592727Salfred * Their data is actually contiguous with this structure so as to make 116117206Salc * it easier to read/write from/to disk. 11792727Salfred */ 118147217Salc _FileRuneRange frl_runetype_ext; 119173708Salc _FileRuneRange frl_maplower_ext; 120173361Skib _FileRuneRange frl_mapupper_ext; 12192727Salfred 12292727Salfred __runepad_t frl_pad4; /* backward compatibility */ 12392727Salfred int32_t frl_variable_len;/* how long that data is */ 12492727Salfred uint32_t frl_pad5; /* backward compatibility */ 12592727Salfred 12692727Salfred /* variable size data follows */ 127106753Salc} __packed _FileRuneLocale; 128157443Speter 129160889Salc 13094777Speter/* magic number for LC_CTYPE (rune)locale declaration */ 13194777Speter#define _RUNECT10_MAGIC "RuneCT10" /* Indicates version 0 of RuneLocale */ 13299571Speter 13392727Salfred/* codeset tag */ 13492727Salfred#define _RUNE_CODESET "CODESET=" 13592727Salfred 136120831Sbms#endif /* !_RUNETYPE_FILE_H_ */ 137120831Sbms