--- /dev/null
+/* $NetBSD: runetype.h,v 1.19 2005/11/29 03:11:59 christos Exp $ */\r
+\r
+/*-\r
+ * Copyright (c) 1993\r
+ * The Regents of the University of California. All rights reserved.\r
+ *\r
+ * This code is derived from software contributed to Berkeley by\r
+ * Paul Borman at Krystal Technologies.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the name of the University nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ * @(#)runetype.h 8.1 (Berkeley) 6/2/93\r
+ */\r
+#ifndef _NB_RUNETYPE_H_\r
+#define _NB_RUNETYPE_H_\r
+\r
+#include <sys/EfiCdefs.h>\r
+#include <sys/types.h>\r
+\r
+/* for cross host tools on older systems */\r
+#ifndef UINT32_C\r
+/* assumes sizeof(unsigned int)>=4 */\r
+#define UINT32_C(c) ((uint32_t)(c##U))\r
+#endif\r
+\r
+typedef uint32_t __nbrune_t;\r
+typedef uint64_t __runepad_t;\r
+\r
+#define _NB_CACHED_RUNES (1 << 8) /* Must be a power of 2 */\r
+#define _NB_RUNE_ISCACHED(c) ((c)>=0 && (c)<_CACHED_RUNES)\r
+\r
+#define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)\r
+\r
+/*\r
+ * The lower 8 bits of runetype[] contain the digit value of the rune.\r
+ */\r
+typedef uint32_t _RuneType;\r
+#define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */\r
+#define _RUNETYPE_C UINT32_C(0x00000200) /* Control */\r
+#define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */\r
+#define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */\r
+#define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */\r
+#define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */\r
+#define _RUNETYPE_S UINT32_C(0x00004000) /* Space */\r
+#define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */\r
+#define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */\r
+#define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */\r
+#define _RUNETYPE_R UINT32_C(0x00040000) /* Print */\r
+#define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */\r
+#define _RUNETYPE_T UINT32_C(0x00100000) /* Special */\r
+#define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */\r
+#define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */\r
+#define _RUNETYPE_SWS 30 /* Bits to shift to get width */\r
+#define _RUNETYPE_SW0 UINT32_C(0x00000000) /* 0 width character */\r
+#define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */\r
+#define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */\r
+#define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */\r
+\r
+\r
+/*\r
+ * rune file format. network endian.\r
+ */\r
+typedef struct {\r
+ int32_t fre_min; /* First rune of the range */\r
+ int32_t fre_max; /* Last rune (inclusive) of the range */\r
+ int32_t fre_map; /* What first maps to in maps */\r
+ uint32_t fre_pad1; /* backward compatibility */\r
+ __runepad_t fre_pad2; /* backward compatibility */\r
+} __attribute__((__packed__)) _FileRuneEntry;\r
+\r
+\r
+typedef struct {\r
+ uint32_t frr_nranges; /* Number of ranges stored */\r
+ uint32_t frr_pad1; /* backward compatibility */\r
+ __runepad_t frr_pad2; /* backward compatibility */\r
+} __attribute__((__packed__)) _FileRuneRange;\r
+\r
+\r
+typedef struct {\r
+ char frl_magic[8]; /* Magic saying what version we are */\r
+ char frl_encoding[32];/* ASCII name of this encoding */\r
+\r
+ __runepad_t frl_pad1; /* backward compatibility */\r
+ __runepad_t frl_pad2; /* backward compatibility */\r
+ int32_t frl_invalid_rune;\r
+ uint32_t frl_pad3; /* backward compatibility */\r
+\r
+ _RuneType frl_runetype[_NB_CACHED_RUNES];\r
+ int32_t frl_maplower[_NB_CACHED_RUNES];\r
+ int32_t frl_mapupper[_NB_CACHED_RUNES];\r
+\r
+ /*\r
+ * The following are to deal with Runes larger than _CACHED_RUNES - 1.\r
+ * Their data is actually contiguous with this structure so as to make\r
+ * it easier to read/write from/to disk.\r
+ */\r
+ _FileRuneRange frl_runetype_ext;\r
+ _FileRuneRange frl_maplower_ext;\r
+ _FileRuneRange frl_mapupper_ext;\r
+\r
+ __runepad_t frl_pad4; /* backward compatibility */\r
+ int32_t frl_variable_len;/* how long that data is */\r
+ uint32_t frl_pad5; /* backward compatibility */\r
+\r
+ /* variable size data follows */\r
+} __attribute__((__packed__)) _FileRuneLocale;\r
+\r
+\r
+/*\r
+ * expanded rune locale declaration. local to the host. host endian.\r
+ */\r
+typedef struct {\r
+ __nbrune_t re_min; /* First rune of the range */\r
+ __nbrune_t re_max; /* Last rune (inclusive) of the range */\r
+ __nbrune_t re_map; /* What first maps to in maps */\r
+ _RuneType *re_rune_types; /* Array of types in range */\r
+} _NBRuneEntry;\r
+\r
+\r
+typedef struct {\r
+ uint32_t rr_nranges; /* Number of ranges stored */\r
+ _NBRuneEntry *rr_rune_ranges;\r
+} _NBRuneRange;\r
+\r
+\r
+/*\r
+ * wctrans stuffs.\r
+ */\r
+typedef struct _WCTransEntry {\r
+ const char *te_name;\r
+ __nbrune_t *te_cached;\r
+ _NBRuneRange *te_extmap;\r
+} _WCTransEntry;\r
+#define _WCTRANS_INDEX_LOWER 0\r
+#define _WCTRANS_INDEX_UPPER 1\r
+#define _WCTRANS_NINDEXES 2\r
+\r
+/*\r
+ * wctype stuffs.\r
+ */\r
+typedef struct _WCTypeEntry {\r
+ const char *te_name;\r
+ _RuneType te_mask;\r
+} _WCTypeEntry;\r
+#define _WCTYPE_INDEX_ALNUM 0\r
+#define _WCTYPE_INDEX_ALPHA 1\r
+#define _WCTYPE_INDEX_BLANK 2\r
+#define _WCTYPE_INDEX_CNTRL 3\r
+#define _WCTYPE_INDEX_DIGIT 4\r
+#define _WCTYPE_INDEX_GRAPH 5\r
+#define _WCTYPE_INDEX_LOWER 6\r
+#define _WCTYPE_INDEX_PRINT 7\r
+#define _WCTYPE_INDEX_PUNCT 8\r
+#define _WCTYPE_INDEX_SPACE 9\r
+#define _WCTYPE_INDEX_UPPER 10\r
+#define _WCTYPE_INDEX_XDIGIT 11\r
+#define _WCTYPE_NINDEXES 12\r
+\r
+/*\r
+ * ctype stuffs\r
+ */\r
+\r
+typedef struct _NBRuneLocale {\r
+ /*\r
+ * copied from _FileRuneLocale\r
+ */\r
+ char rl_magic[8]; /* Magic saying what version we are */\r
+ char rl_encoding[32];/* ASCII name of this encoding */\r
+ __nbrune_t rl_invalid_rune;\r
+ _RuneType rl_runetype[_NB_CACHED_RUNES];\r
+ __nbrune_t rl_maplower[_NB_CACHED_RUNES];\r
+ __nbrune_t rl_mapupper[_NB_CACHED_RUNES];\r
+ _NBRuneRange rl_runetype_ext;\r
+ _NBRuneRange rl_maplower_ext;\r
+ _NBRuneRange rl_mapupper_ext;\r
+\r
+ void *rl_variable;\r
+ size_t rl_variable_len;\r
+\r
+ /*\r
+ * the following portion is generated on the fly\r
+ */\r
+ const char *rl_codeset;\r
+ struct _citrus_ctype_rec *rl_citrus_ctype;\r
+ _WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];\r
+ _WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];\r
+} _NBRuneLocale;\r
+\r
+\r
+/* magic number for LC_CTYPE (rune)locale declaration */\r
+#define _NB_RUNE_MAGIC_1 "RuneCT10" /* Indicates version 0 of RuneLocale */\r
+\r
+/* magic string for dynamic link module - type should be like "LC_CTYPE" */\r
+#define _NB_RUNE_MODULE_1(type) "RuneModule10." type\r
+\r
+/* codeset tag */\r
+#define _NB_RUNE_CODESET "CODESET="\r
+\r
+#endif /* !_NB_RUNETYPE_H_ */\r