1/* $NetBSD: runetype_local.h,v 1.13 2013/04/13 10:21:21 joerg Exp $ */ 2 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 * @(#)rune.h 8.1 (Berkeley) 6/27/93 35 * @(#)runetype.h 8.1 (Berkeley) 6/2/93 36 */ 37 38#ifndef _RUNETYPE_LOCAL_H_ 39#define _RUNETYPE_LOCAL_H_ 40 41#include <sys/cdefs.h> 42#include <sys/types.h> 43#include <stdio.h> 44 45#include "ctype_local.h" 46#include "runetype_file.h" 47 48#define _RUNE_ISCACHED(c) ((c)>=0 && (c)<_CTYPE_CACHE_SIZE) 49 50 51/* 52 * expanded rune locale declaration. local to the host. host endian. 53 */ 54typedef struct { 55 __nbrune_t re_min; /* First rune of the range */ 56 __nbrune_t re_max; /* Last rune (inclusive) of the range */ 57 __nbrune_t re_map; /* What first maps to in maps */ 58 _RuneType *re_rune_types; /* Array of types in range */ 59} _RuneEntry; 60 61 62typedef struct { 63 uint32_t rr_nranges; /* Number of ranges stored */ 64 _RuneEntry *rr_rune_ranges; 65} _RuneRange; 66 67 68/* 69 * wctrans stuffs. 70 */ 71typedef struct _WCTransEntry { 72 const char *te_name; 73 __nbrune_t *te_cached; 74 _RuneRange *te_extmap; 75} _WCTransEntry; 76#define _WCTRANS_INDEX_LOWER 0 77#define _WCTRANS_INDEX_UPPER 1 78#define _WCTRANS_NINDEXES 2 79 80/* 81 * wctype stuffs. 82 */ 83typedef struct _WCTypeEntry { 84 const char *te_name; 85 _RuneType te_mask; 86} _WCTypeEntry; 87#define _WCTYPE_INDEX_ALNUM 0 88#define _WCTYPE_INDEX_ALPHA 1 89#define _WCTYPE_INDEX_BLANK 2 90#define _WCTYPE_INDEX_CNTRL 3 91#define _WCTYPE_INDEX_DIGIT 4 92#define _WCTYPE_INDEX_GRAPH 5 93#define _WCTYPE_INDEX_LOWER 6 94#define _WCTYPE_INDEX_PRINT 7 95#define _WCTYPE_INDEX_PUNCT 8 96#define _WCTYPE_INDEX_SPACE 9 97#define _WCTYPE_INDEX_UPPER 10 98#define _WCTYPE_INDEX_XDIGIT 11 99#define _WCTYPE_NINDEXES 12 100 101/* 102 * ctype stuffs 103 */ 104 105typedef struct _RuneLocale { 106 /* 107 * copied from _FileRuneLocale 108 */ 109 _RuneType rl_runetype[_CTYPE_CACHE_SIZE]; 110 __nbrune_t rl_maplower[_CTYPE_CACHE_SIZE]; 111 __nbrune_t rl_mapupper[_CTYPE_CACHE_SIZE]; 112 _RuneRange rl_runetype_ext; 113 _RuneRange rl_maplower_ext; 114 _RuneRange rl_mapupper_ext; 115 116 void *rl_variable; 117 size_t rl_variable_len; 118 119 /* 120 * the following portion is generated on the fly 121 */ 122 const char *rl_codeset; 123 struct _citrus_ctype_rec *rl_citrus_ctype; 124 _WCTransEntry rl_wctrans[_WCTRANS_NINDEXES]; 125 _WCTypeEntry rl_wctype[_WCTYPE_NINDEXES]; 126 127 const unsigned short *rl_ctype_tab; 128 const short *rl_tolower_tab; 129 const short *rl_toupper_tab; 130 131#ifdef __BUILD_LEGACY 132 const unsigned char *rl_compat_bsdctype; 133#endif 134} _RuneLocale; 135 136/* 137 * global variables 138 */ 139extern __dso_hidden const _RuneLocale _DefaultRuneLocale; 140 141__BEGIN_DECLS 142int _rune_load(const char * __restrict, size_t, _RuneLocale ** __restrict); 143__END_DECLS 144 145#endif /* !_RUNETYPE_LOCAL_H_ */ 146