1 /* $XTermId: other.h,v 1.12 2010/11/26 20:28:13 tom Exp $ */ 2 3 /* 4 Copyright (c) 2002 by Tomohiro KUBOTA 5 6 Permission is hereby granted, free of charge, to any person obtaining a copy 7 of this software and associated documentation files (the "Software"), to deal 8 in the Software without restriction, including without limitation the rights 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 copies of the Software, and to permit persons to whom the Software is 11 furnished to do so, subject to the following conditions: 12 13 The above copyright notice and this permission notice shall be included in 14 all copies or substantial portions of the Software. 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 THE SOFTWARE. 23 */ 24 25 #ifndef LUIT_OTHER_H 26 #define LUIT_OTHER_H 1 27 28 #include <luit.h> /* include this, for self-contained headers */ 29 30 #include <luitconv.h> 31 #include <trace.h> 32 33 #undef UCHAR 34 #define UCHAR unsigned char 35 36 #undef UINT 37 #define UINT unsigned int 38 39 #define UChar(n) ((UCHAR)(n)) 40 41 typedef struct { 42 FontMapPtr mapping; 43 FontMapReversePtr reverse; 44 int buf; 45 } aux_gbk; 46 47 typedef struct { 48 UCHAR buf[4]; 49 int buf_ptr, len; 50 } aux_utf8; 51 52 typedef struct { 53 FontMapPtr x0208mapping; 54 FontMapPtr x0201mapping; 55 FontMapReversePtr x0208reverse; 56 FontMapReversePtr x0201reverse; 57 int buf; 58 } aux_sjis; 59 60 typedef struct { 61 FontMapPtr mapping; 62 FontMapReversePtr reverse; 63 int buf; 64 } aux_hkscs; 65 66 typedef struct { 67 FontMapPtr cs0_mapping; /* gb18030.2000-0 */ 68 FontMapReversePtr cs0_reverse; 69 70 FontMapPtr cs1_mapping; /* gb18030.2000-1 */ 71 FontMapReversePtr cs1_reverse; 72 73 int linear; /* set to '1' if stack_gb18030 linearized a 4bytes seq */ 74 int buf[3]; 75 int buf_ptr; 76 } aux_gb18030; 77 78 typedef union { 79 aux_gbk gbk; 80 aux_utf8 utf8; 81 aux_sjis sjis; 82 aux_hkscs hkscs; 83 aux_gb18030 gb18030; 84 } OtherState, *OtherStatePtr; 85 86 int init_gbk(OtherStatePtr); 87 UINT mapping_gbk(UINT, OtherStatePtr); 88 UINT reverse_gbk(UINT, OtherStatePtr); 89 int stack_gbk(UINT, OtherStatePtr); 90 91 int init_utf8(OtherStatePtr); 92 UINT mapping_utf8(UINT, OtherStatePtr); 93 UINT reverse_utf8(UINT, OtherStatePtr); 94 int stack_utf8(UINT, OtherStatePtr); 95 96 int init_sjis(OtherStatePtr); 97 UINT mapping_sjis(UINT, OtherStatePtr); 98 UINT reverse_sjis(UINT, OtherStatePtr); 99 int stack_sjis(UINT, OtherStatePtr); 100 101 int init_hkscs(OtherStatePtr); 102 UINT mapping_hkscs(UINT, OtherStatePtr); 103 UINT reverse_hkscs(UINT, OtherStatePtr); 104 int stack_hkscs(UINT, OtherStatePtr); 105 106 int init_gb18030(OtherStatePtr); 107 UINT mapping_gb18030(UINT, OtherStatePtr); 108 UINT reverse_gb18030(UINT, OtherStatePtr); 109 int stack_gb18030(UINT, OtherStatePtr); 110 111 #endif /* LUIT_OTHER_H */ 112